无法更改粗体文字颜色,仍保留“黑色边框" [英] Can't change bold text color, a 'black border' remains

查看:63
本文介绍了无法更改粗体文字颜色,仍保留“黑色边框"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我更改文本的颜色时,会得到以下结果:

When I change the color of the text I get the following result:

是什么造成了这个黑色边框?

What is creating this black border?

当我使用带有嵌入式字体的飞碟生成PDF并尝试更改h1,h2等的颜色时,会发生此问题.如果我将html飞碟用于将PDF生成到磁盘并转储,在Chrome中打开它,可以正确应用颜色更改,没有奇怪的黑色边框.

This problem occurs when I'm generating a PDF using flying saucer, with an embedded font, and try to change the color on h1, h2, etc. If I dump the html flying saucer uses to generate the PDF to disk and open it in Chrome the color change is applied correctly, with no weird black border.

推荐答案

字体程序包含绘制一组字形所需的所有路径构造运算符.当您使用字体中的字形时,这些绘制指令将与路径绘制运算符一起执行.默认情况下,路径绘制运算符是填充"运算符.没有绘制边框,仅使用当前的填充颜色填充形状.这称为默认的渲染模式.

A font program contains all the path construction operators that are needed to draw a set of glyphs. When you use a glyph from a font, these drawing instructions are executed along with a path painting operator. By default, the path painting operator is a "fill" operator. No borders are drawn, the shape is just filled using the current fill color. This is called the default render mode.

其他渲染模式例如是笔触",它使用当前笔触颜色绘制字形的轮廓,但不填充它.或填充和笔触"使用默认的笔触颜色绘制轮廓,并使用默认的填充色填充路径.还有一种渲染模式不可见",在这种情况下,不会触碰任何东西,也不会填充任何东西.

Other rendermodes are for instance "stroke" which draws the outlines of the glyph using the current stroke color, but doesn't fill it. Or "fill and stroke" which draws the outlines using the default stroke color and fills the path using the default fill color. There's also a render mode "invisible" in which case nothing is stroked, nothing is filled.

查看您的图像,似乎使用的渲染模式将字形填充为灰色,并使用黑色对其进行描边(并且线宽似乎很粗).如果我不得不猜测,我会说您正在尝试模仿粗体".以粗体显示文本的最佳方法是从常规字体(例如arial.ttf)切换为粗体(例如arialbd.ttf).不幸的是,并非每种字体都有粗体(例如,有arialuni.ttf,但没有arialunibd.ttf).在这种情况下,通过将渲染模式更改为填充和描边"来模仿粗体,并更改线宽以使字形具有粗体外观.这可能就是您的情况.

Looking at your image, it seems like the render mode that is used fills the glyph in gray and strokes it using black (and the line width seems to be quite thick). If I had to guess, I'd say that you're trying to mimic "bold". The best way to draw text in bold, is to switch from a regular font (e.g. arial.ttf) to a bold font (e.g. arialbd.ttf). Unfortunately, not every font has a bold counterpart (e.g. there's arialuni.ttf, but no arialunibd.ttf). In that case, bold is mimicked by changing the render mode to "fill and stroke" and the line width is changed to give the glyphs a bold appearance. This could be what is happening in your case.

检查您的HTML:您有没有机会谈论粗体字?如果是这样,也许您应该更改字体以及颜色.这样,您将使用 true 粗体字体而不是 pseudo 假字体.

Check your HTML: are you by any chance talking about text that is in bold? If so, maybe you should change the font along with the color. That way, you'll use a true bold font instead of a pseudo false font.

免责声明::我不知道飞碟,也不想知道.飞碟正在使用iText生成PDF. iText是我编写的一个库,但是Flying Saucer在使用它时并未与我经营的iText Group NV建立业务关系.因此,飞碟的创建者有责任支持他们的软件.

DISCLAIMER: I don't know Flying Saucer and I don't want to know it. Flying Saucer is using iText for PDF generation. iText is a library I wrote, but Flying Saucer is using it without having established a business relationship with iText Group NV, which is a company I run. Hence it's the responsibility of the creators of Flying Saucer to support their software.

这篇关于无法更改粗体文字颜色,仍保留“黑色边框"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆