Loading core/tests/coretests/assets/fonts/HintedAdvanceWidthTest-Regular.ttf 0 → 100644 +1.11 KiB File added.No diff preview for this file type. View file core/tests/coretests/assets/fonts/HintedAdvanceWidthTest-Regular.ttx 0 → 100644 +328 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0"> <GlyphOrder> <!-- The 'id' attribute is only for humans; it is ignored when parsed. --> <GlyphID id="0" name=".notdef"/> <GlyphID id="1" name="space"/> <GlyphID id="9" name="H"/> <GlyphID id="16" name="O"/> </GlyphOrder> <head> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="1.0"/> <fontRevision value="1.0"/> <checkSumAdjustment value="0x640cdb2f"/> <magicNumber value="0x5f0f3cf5"/> <flags value="00000000 00000011"/> <unitsPerEm value="1000"/> <created value="Wed Sep 9 08:01:17 2015"/> <modified value="Wed Sep 9 08:48:07 2015"/> <xMin value="30"/> <yMin value="-200"/> <xMax value="629"/> <yMax value="800"/> <macStyle value="00000000 00000000"/> <lowestRecPPEM value="7"/> <fontDirectionHint value="2"/> <indexToLocFormat value="0"/> <glyphDataFormat value="0"/> </head> <hhea> <tableVersion value="1.0"/> <ascent value="1000"/> <descent value="-200"/> <lineGap value="0"/> <advanceWidthMax value="659"/> <minLeftSideBearing value="0"/> <minRightSideBearing value="30"/> <xMaxExtent value="629"/> <caretSlopeRise value="1"/> <caretSlopeRun value="0"/> <caretOffset value="0"/> <reserved0 value="0"/> <reserved1 value="0"/> <reserved2 value="0"/> <reserved3 value="0"/> <metricDataFormat value="0"/> <numberOfHMetrics value="18"/> </hhea> <maxp> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="0x10000"/> <numGlyphs value="54"/> <maxPoints value="73"/> <maxContours value="10"/> <maxCompositePoints value="0"/> <maxCompositeContours value="0"/> <maxZones value="2"/> <maxTwilightPoints value="12"/> <maxStorage value="28"/> <maxFunctionDefs value="119"/> <maxInstructionDefs value="0"/> <maxStackElements value="61"/> <maxSizeOfInstructions value="2967"/> <maxComponentElements value="0"/> <maxComponentDepth value="0"/> </maxp> <OS_2> <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex' will be recalculated by the compiler --> <version value="3"/> <xAvgCharWidth value="594"/> <usWeightClass value="400"/> <usWidthClass value="5"/> <fsType value="00000000 00001000"/> <ySubscriptXSize value="650"/> <ySubscriptYSize value="600"/> <ySubscriptXOffset value="0"/> <ySubscriptYOffset value="75"/> <ySuperscriptXSize value="650"/> <ySuperscriptYSize value="600"/> <ySuperscriptXOffset value="0"/> <ySuperscriptYOffset value="350"/> <yStrikeoutSize value="50"/> <yStrikeoutPosition value="300"/> <sFamilyClass value="0"/> <panose> <bFamilyType value="0"/> <bSerifStyle value="0"/> <bWeight value="5"/> <bProportion value="0"/> <bContrast value="0"/> <bStrokeVariation value="0"/> <bArmStyle value="0"/> <bLetterForm value="0"/> <bMidline value="0"/> <bXHeight value="0"/> </panose> <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/> <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/> <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/> <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/> <achVendID value="UKWN"/> <fsSelection value="00000000 01000000"/> <usFirstCharIndex value="32"/> <usLastCharIndex value="122"/> <sTypoAscender value="800"/> <sTypoDescender value="-200"/> <sTypoLineGap value="200"/> <usWinAscent value="1000"/> <usWinDescent value="200"/> <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/> <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/> <sxHeight value="500"/> <sCapHeight value="700"/> <usDefaultChar value="0"/> <usBreakChar value="32"/> <usMaxContext value="0"/> </OS_2> <hmtx> <mtx name=".notdef" width="500" lsb="93"/> <mtx name="H" width="627" lsb="50"/> <mtx name="O" width="659" lsb="30"/> <mtx name="space" width="300" lsb="0"/> </hmtx> <cmap> <tableVersion version="0"/> <cmap_format_4 platformID="0" platEncID="3" language="0"> <map code="0x20" name="space"/><!-- SPACE --> <map code="0x48" name="H"/><!-- LATIN CAPITAL LETTER H --> <map code="0x4f" name="O"/><!-- LATIN CAPITAL LETTER O --> </cmap_format_4> <cmap_format_4 platformID="3" platEncID="1" language="0"> <map code="0x20" name="space"/><!-- SPACE --> <map code="0x48" name="H"/><!-- LATIN CAPITAL LETTER H --> <map code="0x4f" name="O"/><!-- LATIN CAPITAL LETTER O --> </cmap_format_4> </cmap> <fpgm> <assembly> </assembly> </fpgm> <prep> <assembly> </assembly> </prep> <cvt> <cv index="0" value="0"/> </cvt> <loca> <!-- The 'loca' table will be calculated by the compiler --> </loca> <glyf> <!-- The xMin, yMin, xMax and yMax values will be recalculated by the compiler. --> <TTGlyph name=".notdef" xMin="93" yMin="-200" xMax="410" yMax="800"> <contour> <pt x="410" y="0" on="1"/> <pt x="50" y="0" on="1"/> <pt x="50" y="700" on="1"/> <pt x="410" y="700" on="1"/> </contour> <instructions><assembly> PUSHB[] 1 2 4 3 SLOOP[] PUSH[] -400 SHPIX[] PUSHB[] 0 3 5 3 SLOOP[] PUSH[] 400 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="H" xMin="50" yMin="0" xMax="577" yMax="700"> <contour> <pt x="50" y="700" on="1"/> <pt x="200" y="700" on="1"/> <pt x="200" y="447" on="1"/> <pt x="427" y="447" on="1"/> <pt x="427" y="700" on="1"/> <pt x="577" y="700" on="1"/> <pt x="577" y="0" on="1"/> <pt x="427" y="0" on="1"/> <pt x="427" y="297" on="1"/> <pt x="200" y="297" on="1"/> <pt x="200" y="0" on="1"/> <pt x="50" y="0" on="1"/> </contour> <instructions><assembly> PUSHB[] 0 11 12 3 SLOOP[] PUSH[] -200 SHPIX[] PUSHB[] 5 6 13 3 SLOOP[] PUSH[] 200 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="O" xMin="30" yMin="0" xMax="629" yMax="700"> <contour> <pt x="248" y="0" on="0"/> <pt x="111" y="94" on="0"/> <pt x="30" y="255" on="0"/> <pt x="30" y="350" on="1"/> <pt x="30" y="445" on="0"/> <pt x="111" y="606" on="0"/> <pt x="248" y="700" on="0"/> <pt x="330" y="700" on="1"/> <pt x="411" y="700" on="0"/> <pt x="548" y="606" on="0"/> <pt x="629" y="445" on="0"/> <pt x="629" y="350" on="1"/> <pt x="629" y="255" on="0"/> <pt x="548" y="94" on="0"/> <pt x="411" y="0" on="0"/> <pt x="330" y="0" on="1"/> </contour> <contour> <pt x="370" y="150" on="0"/> <pt x="439" y="209" on="0"/> <pt x="480" y="302" on="0"/> <pt x="480" y="350" on="1"/> <pt x="480" y="398" on="0"/> <pt x="439" y="491" on="0"/> <pt x="370" y="550" on="0"/> <pt x="330" y="550" on="1"/> <pt x="289" y="550" on="0"/> <pt x="220" y="491" on="0"/> <pt x="179" y="398" on="0"/> <pt x="179" y="350" on="1"/> <pt x="179" y="302" on="0"/> <pt x="220" y="209" on="0"/> <pt x="289" y="150" on="0"/> <pt x="330" y="150" on="1"/> </contour> <instructions><assembly> PUSH[] 32 -200 SHPIX[] PUSHB[] 33 200 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="space"> <contour></contour> <instructions><assembly> PUSH[] 0 -200 SHPIX[] PUSHB[] 1 200 SHPIX[] </assembly></instructions> </TTGlyph> </glyf> <name> <namerecord nameID="1" platformID="1" platEncID="0" langID="0x0" unicode="True"> Hinted Advance Width Test </namerecord> <namerecord nameID="2" platformID="1" platEncID="0" langID="0x0" unicode="True"> Regular </namerecord> <namerecord nameID="4" platformID="1" platEncID="0" langID="0x0" unicode="True"> Hinted Advance Width Test </namerecord> <namerecord nameID="6" platformID="1" platEncID="0" langID="0x0" unicode="True"> HintedAdvanceWidthTest-Regular </namerecord> <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409"> Hinted Advance Width Test </namerecord> <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409"> Regular </namerecord> <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409"> Hinted Advance Width Test </namerecord> <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409"> HintedAdvanceWidthTest-Regular </namerecord> </name> <post> <formatType value="2.0"/> <italicAngle value="0.0"/> <underlinePosition value="-75"/> <underlineThickness value="50"/> <isFixedPitch value="0"/> <minMemType42 value="0"/> <maxMemType42 value="0"/> <minMemType1 value="0"/> <maxMemType1 value="0"/> <psNames> <!-- This file uses unique glyph names based on the information found in the 'post' table. Since these names might not be unique, we have to invent artificial names in case of clashes. In order to be able to retain the original information, we need a name to ps name mapping for those cases where they differ. That's what you see below. --> </psNames> <extraNames> <!-- following are the name that are not taken from the standard Mac glyph order --> </extraNames> </post> <gasp> <gaspRange rangeMaxPPEM="65535" rangeGaspBehavior="15"/> </gasp> </ttFont> core/tests/coretests/src/android/graphics/PaintTest.java 0 → 100644 +97 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import android.graphics.Paint; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; /** * PaintTest tests {@link Paint}. */ public class PaintTest extends InstrumentationTestCase { private static final String FONT_PATH = "fonts/HintedAdvanceWidthTest-Regular.ttf"; static void assertEquals(String message, float[] expected, float[] actual) { if (expected.length != actual.length) { fail(message + " expected array length:<" + expected.length + "> but was:<" + actual.length + ">"); } for (int i = 0; i < expected.length; ++i) { if (expected[i] != actual[i]) { fail(message + " expected array element[" +i + "]:<" + expected[i] + ">but was:<" + actual[i] + ">"); } } } static class HintingTestCase { public final String mText; public final float mTextSize; public final float[] mWidthWithoutHinting; public final float[] mWidthWithHinting; public HintingTestCase(String text, float textSize, float[] widthWithoutHinting, float[] widthWithHinting) { mText = text; mTextSize = textSize; mWidthWithoutHinting = widthWithoutHinting; mWidthWithHinting = widthWithHinting; } } // Following test cases are only valid for HintedAdvanceWidthTest-Regular.ttf in assets/fonts. HintingTestCase[] HINTING_TESTCASES = { new HintingTestCase("H", 11f, new float[] { 7f }, new float[] { 13f }), new HintingTestCase("O", 11f, new float[] { 7f }, new float[] { 13f }), new HintingTestCase("H", 13f, new float[] { 8f }, new float[] { 14f }), new HintingTestCase("O", 13f, new float[] { 9f }, new float[] { 15f }), new HintingTestCase("HO", 11f, new float[] { 7f, 7f }, new float[] { 13f, 13f }), new HintingTestCase("OH", 11f, new float[] { 7f, 7f }, new float[] { 13f, 13f }), new HintingTestCase("HO", 13f, new float[] { 8f, 9f }, new float[] { 14f, 15f }), new HintingTestCase("OH", 13f, new float[] { 9f, 8f }, new float[] { 15f, 14f }), }; @SmallTest public void testHintingWidth() { final Typeface fontTypeface = Typeface.createFromAsset( getInstrumentation().getContext().getAssets(), FONT_PATH); Paint paint = new Paint(); paint.setTypeface(fontTypeface); for (int i = 0; i < HINTING_TESTCASES.length; ++i) { HintingTestCase testCase = HINTING_TESTCASES[i]; paint.setTextSize(testCase.mTextSize); float[] widths = new float[testCase.mText.length()]; paint.setHinting(Paint.HINTING_OFF); paint.getTextWidths(String.valueOf(testCase.mText), widths); assertEquals("Text width of '" + testCase.mText + "' without hinting is not expected.", testCase.mWidthWithoutHinting, widths); paint.setHinting(Paint.HINTING_ON); paint.getTextWidths(String.valueOf(testCase.mText), widths); assertEquals("Text width of '" + testCase.mText + "' with hinting is not expected.", testCase.mWidthWithHinting, widths); } } } Loading
core/tests/coretests/assets/fonts/HintedAdvanceWidthTest-Regular.ttf 0 → 100644 +1.11 KiB File added.No diff preview for this file type. View file
core/tests/coretests/assets/fonts/HintedAdvanceWidthTest-Regular.ttx 0 → 100644 +328 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0"> <GlyphOrder> <!-- The 'id' attribute is only for humans; it is ignored when parsed. --> <GlyphID id="0" name=".notdef"/> <GlyphID id="1" name="space"/> <GlyphID id="9" name="H"/> <GlyphID id="16" name="O"/> </GlyphOrder> <head> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="1.0"/> <fontRevision value="1.0"/> <checkSumAdjustment value="0x640cdb2f"/> <magicNumber value="0x5f0f3cf5"/> <flags value="00000000 00000011"/> <unitsPerEm value="1000"/> <created value="Wed Sep 9 08:01:17 2015"/> <modified value="Wed Sep 9 08:48:07 2015"/> <xMin value="30"/> <yMin value="-200"/> <xMax value="629"/> <yMax value="800"/> <macStyle value="00000000 00000000"/> <lowestRecPPEM value="7"/> <fontDirectionHint value="2"/> <indexToLocFormat value="0"/> <glyphDataFormat value="0"/> </head> <hhea> <tableVersion value="1.0"/> <ascent value="1000"/> <descent value="-200"/> <lineGap value="0"/> <advanceWidthMax value="659"/> <minLeftSideBearing value="0"/> <minRightSideBearing value="30"/> <xMaxExtent value="629"/> <caretSlopeRise value="1"/> <caretSlopeRun value="0"/> <caretOffset value="0"/> <reserved0 value="0"/> <reserved1 value="0"/> <reserved2 value="0"/> <reserved3 value="0"/> <metricDataFormat value="0"/> <numberOfHMetrics value="18"/> </hhea> <maxp> <!-- Most of this table will be recalculated by the compiler --> <tableVersion value="0x10000"/> <numGlyphs value="54"/> <maxPoints value="73"/> <maxContours value="10"/> <maxCompositePoints value="0"/> <maxCompositeContours value="0"/> <maxZones value="2"/> <maxTwilightPoints value="12"/> <maxStorage value="28"/> <maxFunctionDefs value="119"/> <maxInstructionDefs value="0"/> <maxStackElements value="61"/> <maxSizeOfInstructions value="2967"/> <maxComponentElements value="0"/> <maxComponentDepth value="0"/> </maxp> <OS_2> <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex' will be recalculated by the compiler --> <version value="3"/> <xAvgCharWidth value="594"/> <usWeightClass value="400"/> <usWidthClass value="5"/> <fsType value="00000000 00001000"/> <ySubscriptXSize value="650"/> <ySubscriptYSize value="600"/> <ySubscriptXOffset value="0"/> <ySubscriptYOffset value="75"/> <ySuperscriptXSize value="650"/> <ySuperscriptYSize value="600"/> <ySuperscriptXOffset value="0"/> <ySuperscriptYOffset value="350"/> <yStrikeoutSize value="50"/> <yStrikeoutPosition value="300"/> <sFamilyClass value="0"/> <panose> <bFamilyType value="0"/> <bSerifStyle value="0"/> <bWeight value="5"/> <bProportion value="0"/> <bContrast value="0"/> <bStrokeVariation value="0"/> <bArmStyle value="0"/> <bLetterForm value="0"/> <bMidline value="0"/> <bXHeight value="0"/> </panose> <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/> <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/> <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/> <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/> <achVendID value="UKWN"/> <fsSelection value="00000000 01000000"/> <usFirstCharIndex value="32"/> <usLastCharIndex value="122"/> <sTypoAscender value="800"/> <sTypoDescender value="-200"/> <sTypoLineGap value="200"/> <usWinAscent value="1000"/> <usWinDescent value="200"/> <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/> <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/> <sxHeight value="500"/> <sCapHeight value="700"/> <usDefaultChar value="0"/> <usBreakChar value="32"/> <usMaxContext value="0"/> </OS_2> <hmtx> <mtx name=".notdef" width="500" lsb="93"/> <mtx name="H" width="627" lsb="50"/> <mtx name="O" width="659" lsb="30"/> <mtx name="space" width="300" lsb="0"/> </hmtx> <cmap> <tableVersion version="0"/> <cmap_format_4 platformID="0" platEncID="3" language="0"> <map code="0x20" name="space"/><!-- SPACE --> <map code="0x48" name="H"/><!-- LATIN CAPITAL LETTER H --> <map code="0x4f" name="O"/><!-- LATIN CAPITAL LETTER O --> </cmap_format_4> <cmap_format_4 platformID="3" platEncID="1" language="0"> <map code="0x20" name="space"/><!-- SPACE --> <map code="0x48" name="H"/><!-- LATIN CAPITAL LETTER H --> <map code="0x4f" name="O"/><!-- LATIN CAPITAL LETTER O --> </cmap_format_4> </cmap> <fpgm> <assembly> </assembly> </fpgm> <prep> <assembly> </assembly> </prep> <cvt> <cv index="0" value="0"/> </cvt> <loca> <!-- The 'loca' table will be calculated by the compiler --> </loca> <glyf> <!-- The xMin, yMin, xMax and yMax values will be recalculated by the compiler. --> <TTGlyph name=".notdef" xMin="93" yMin="-200" xMax="410" yMax="800"> <contour> <pt x="410" y="0" on="1"/> <pt x="50" y="0" on="1"/> <pt x="50" y="700" on="1"/> <pt x="410" y="700" on="1"/> </contour> <instructions><assembly> PUSHB[] 1 2 4 3 SLOOP[] PUSH[] -400 SHPIX[] PUSHB[] 0 3 5 3 SLOOP[] PUSH[] 400 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="H" xMin="50" yMin="0" xMax="577" yMax="700"> <contour> <pt x="50" y="700" on="1"/> <pt x="200" y="700" on="1"/> <pt x="200" y="447" on="1"/> <pt x="427" y="447" on="1"/> <pt x="427" y="700" on="1"/> <pt x="577" y="700" on="1"/> <pt x="577" y="0" on="1"/> <pt x="427" y="0" on="1"/> <pt x="427" y="297" on="1"/> <pt x="200" y="297" on="1"/> <pt x="200" y="0" on="1"/> <pt x="50" y="0" on="1"/> </contour> <instructions><assembly> PUSHB[] 0 11 12 3 SLOOP[] PUSH[] -200 SHPIX[] PUSHB[] 5 6 13 3 SLOOP[] PUSH[] 200 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="O" xMin="30" yMin="0" xMax="629" yMax="700"> <contour> <pt x="248" y="0" on="0"/> <pt x="111" y="94" on="0"/> <pt x="30" y="255" on="0"/> <pt x="30" y="350" on="1"/> <pt x="30" y="445" on="0"/> <pt x="111" y="606" on="0"/> <pt x="248" y="700" on="0"/> <pt x="330" y="700" on="1"/> <pt x="411" y="700" on="0"/> <pt x="548" y="606" on="0"/> <pt x="629" y="445" on="0"/> <pt x="629" y="350" on="1"/> <pt x="629" y="255" on="0"/> <pt x="548" y="94" on="0"/> <pt x="411" y="0" on="0"/> <pt x="330" y="0" on="1"/> </contour> <contour> <pt x="370" y="150" on="0"/> <pt x="439" y="209" on="0"/> <pt x="480" y="302" on="0"/> <pt x="480" y="350" on="1"/> <pt x="480" y="398" on="0"/> <pt x="439" y="491" on="0"/> <pt x="370" y="550" on="0"/> <pt x="330" y="550" on="1"/> <pt x="289" y="550" on="0"/> <pt x="220" y="491" on="0"/> <pt x="179" y="398" on="0"/> <pt x="179" y="350" on="1"/> <pt x="179" y="302" on="0"/> <pt x="220" y="209" on="0"/> <pt x="289" y="150" on="0"/> <pt x="330" y="150" on="1"/> </contour> <instructions><assembly> PUSH[] 32 -200 SHPIX[] PUSHB[] 33 200 SHPIX[] </assembly></instructions> </TTGlyph> <TTGlyph name="space"> <contour></contour> <instructions><assembly> PUSH[] 0 -200 SHPIX[] PUSHB[] 1 200 SHPIX[] </assembly></instructions> </TTGlyph> </glyf> <name> <namerecord nameID="1" platformID="1" platEncID="0" langID="0x0" unicode="True"> Hinted Advance Width Test </namerecord> <namerecord nameID="2" platformID="1" platEncID="0" langID="0x0" unicode="True"> Regular </namerecord> <namerecord nameID="4" platformID="1" platEncID="0" langID="0x0" unicode="True"> Hinted Advance Width Test </namerecord> <namerecord nameID="6" platformID="1" platEncID="0" langID="0x0" unicode="True"> HintedAdvanceWidthTest-Regular </namerecord> <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409"> Hinted Advance Width Test </namerecord> <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409"> Regular </namerecord> <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409"> Hinted Advance Width Test </namerecord> <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409"> HintedAdvanceWidthTest-Regular </namerecord> </name> <post> <formatType value="2.0"/> <italicAngle value="0.0"/> <underlinePosition value="-75"/> <underlineThickness value="50"/> <isFixedPitch value="0"/> <minMemType42 value="0"/> <maxMemType42 value="0"/> <minMemType1 value="0"/> <maxMemType1 value="0"/> <psNames> <!-- This file uses unique glyph names based on the information found in the 'post' table. Since these names might not be unique, we have to invent artificial names in case of clashes. In order to be able to retain the original information, we need a name to ps name mapping for those cases where they differ. That's what you see below. --> </psNames> <extraNames> <!-- following are the name that are not taken from the standard Mac glyph order --> </extraNames> </post> <gasp> <gaspRange rangeMaxPPEM="65535" rangeGaspBehavior="15"/> </gasp> </ttFont>
core/tests/coretests/src/android/graphics/PaintTest.java 0 → 100644 +97 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import android.graphics.Paint; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; /** * PaintTest tests {@link Paint}. */ public class PaintTest extends InstrumentationTestCase { private static final String FONT_PATH = "fonts/HintedAdvanceWidthTest-Regular.ttf"; static void assertEquals(String message, float[] expected, float[] actual) { if (expected.length != actual.length) { fail(message + " expected array length:<" + expected.length + "> but was:<" + actual.length + ">"); } for (int i = 0; i < expected.length; ++i) { if (expected[i] != actual[i]) { fail(message + " expected array element[" +i + "]:<" + expected[i] + ">but was:<" + actual[i] + ">"); } } } static class HintingTestCase { public final String mText; public final float mTextSize; public final float[] mWidthWithoutHinting; public final float[] mWidthWithHinting; public HintingTestCase(String text, float textSize, float[] widthWithoutHinting, float[] widthWithHinting) { mText = text; mTextSize = textSize; mWidthWithoutHinting = widthWithoutHinting; mWidthWithHinting = widthWithHinting; } } // Following test cases are only valid for HintedAdvanceWidthTest-Regular.ttf in assets/fonts. HintingTestCase[] HINTING_TESTCASES = { new HintingTestCase("H", 11f, new float[] { 7f }, new float[] { 13f }), new HintingTestCase("O", 11f, new float[] { 7f }, new float[] { 13f }), new HintingTestCase("H", 13f, new float[] { 8f }, new float[] { 14f }), new HintingTestCase("O", 13f, new float[] { 9f }, new float[] { 15f }), new HintingTestCase("HO", 11f, new float[] { 7f, 7f }, new float[] { 13f, 13f }), new HintingTestCase("OH", 11f, new float[] { 7f, 7f }, new float[] { 13f, 13f }), new HintingTestCase("HO", 13f, new float[] { 8f, 9f }, new float[] { 14f, 15f }), new HintingTestCase("OH", 13f, new float[] { 9f, 8f }, new float[] { 15f, 14f }), }; @SmallTest public void testHintingWidth() { final Typeface fontTypeface = Typeface.createFromAsset( getInstrumentation().getContext().getAssets(), FONT_PATH); Paint paint = new Paint(); paint.setTypeface(fontTypeface); for (int i = 0; i < HINTING_TESTCASES.length; ++i) { HintingTestCase testCase = HINTING_TESTCASES[i]; paint.setTextSize(testCase.mTextSize); float[] widths = new float[testCase.mText.length()]; paint.setHinting(Paint.HINTING_OFF); paint.getTextWidths(String.valueOf(testCase.mText), widths); assertEquals("Text width of '" + testCase.mText + "' without hinting is not expected.", testCase.mWidthWithoutHinting, widths); paint.setHinting(Paint.HINTING_ON); paint.getTextWidths(String.valueOf(testCase.mText), widths); assertEquals("Text width of '" + testCase.mText + "' with hinting is not expected.", testCase.mWidthWithHinting, widths); } } }