[SVG -> OTF Converter] Force UnitsPerEm to 1000
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2015 00:57:41 +0000 (00:57 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2015 00:57:41 +0000 (00:57 +0000)
commit932752a953068828934b42b36cf67c673a45a86c
tree1d81d786221765ab4e2b16692f2f3958f661265a
parentaf41d6284b25cf3fbbc4d6ce8d64132eac9edb22
[SVG -> OTF Converter] Force UnitsPerEm to 1000
https://bugs.webkit.org/show_bug.cgi?id=151650

Reviewed by Antti Koivisto.

Source/WebCore:

According to the Adobe Type 1 Font Format:

"Type 1 font programs generally use a 1000 to 1 scaling matrix
for the definition of the relationship of character space unites
to user space units."

Windows actually disregards the "unitsPerEm" value in the "head"
table for some calculations, and hardcodes 1000 instead. In order
to have consistent renderings on Windows and OS X, this patch
forces all generated fonts to have a unitsPerEm of 1000, and
appropriately scales all necessary values.

Test: svg/W3C-SVG-1.1/fonts-elem-03-b.svg

* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::scaleUnitsPerEm):
(WebCore::SVGToOTFFontConverter::appendHEADTable):
(WebCore::SVGToOTFFontConverter::appendOS2Table):
(WebCore::SVGToOTFFontConverter::appendVORGTable):
(WebCore::SVGToOTFFontConverter::appendVHEATable):
(WebCore::SVGToOTFFontConverter::appendVMTXTable):
(WebCore::SVGToOTFFontConverter::addKerningPair):
(WebCore::CFFBuilder::CFFBuilder):
(WebCore::CFFBuilder::boundingBox):
(WebCore::CFFBuilder::updateBoundingBox):
(WebCore::CFFBuilder::unscaledLineTo):
(WebCore::SVGToOTFFontConverter::transcodeGlyphPaths):
(WebCore::SVGToOTFFontConverter::processGlyphElement):
(WebCore::SVGToOTFFontConverter::appendLigatureGlyphs):
(WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter):

LayoutTests:

Some tests have quantization differences.

* fast/ruby/ruby-expansion-cjk-2-expected.html:
* fast/ruby/ruby-expansion-cjk-3-expected.html:
* fast/ruby/ruby-expansion-cjk-4-expected.html:
* fast/ruby/ruby-expansion-cjk-5-expected.html:
* fast/ruby/ruby-expansion-cjk-expected.html:
* platform/mac-wk2/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/fonts-elem-01-t-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/fonts-elem-02-t-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/text-intro-01-t-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/text-intro-02-b-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/text-intro-03-b-expected.txt:
* platform/mac/svg/W3C-SVG-1.1/text-intro-04-t-expected.txt:
* platform/mac/svg/batik/text/textEffect3-expected.txt:
* platform/mac/svg/batik/text/textPosition2-expected.txt:
* platform/mac/svg/wicd/test-rightsizing-b-expected.txt:
* svg/custom/acid3-test-77-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/ruby/ruby-expansion-cjk-2-expected.html
LayoutTests/fast/ruby/ruby-expansion-cjk-3-expected.html
LayoutTests/fast/ruby/ruby-expansion-cjk-4-expected.html
LayoutTests/fast/ruby/ruby-expansion-cjk-5-expected.html
LayoutTests/fast/ruby/ruby-expansion-cjk-expected.html
LayoutTests/platform/mac-wk2/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-01-t-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-02-t-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-03-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-04-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-elem-07-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-intro-01-t-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-intro-02-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-intro-03-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-intro-04-t-expected.txt
LayoutTests/platform/mac/svg/batik/text/textEffect3-expected.txt
LayoutTests/platform/mac/svg/batik/text/textPosition2-expected.txt
LayoutTests/platform/mac/svg/wicd/test-rightsizing-b-expected.txt
LayoutTests/svg/custom/acid3-test-77-expected.txt
LayoutTests/svg/custom/acid3-test-77.html
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGToOTFFontConversion.cpp