add get_glyph_from_name & test. use hb_string_array
This commit is contained in:
parent
51e7728521
commit
ff87465b40
@ -334,6 +334,7 @@ noinst_PROGRAMS = \
|
||||
test-buffer-serialize \
|
||||
test-ot-meta \
|
||||
test-ot-name \
|
||||
test-ot-glyphname \
|
||||
test-gpos-size-params \
|
||||
test-gsub-would-substitute \
|
||||
$(NULL)
|
||||
@ -359,6 +360,10 @@ test_ot_name_SOURCES = test-ot-name.cc
|
||||
test_ot_name_CPPFLAGS = $(HBCFLAGS)
|
||||
test_ot_name_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_ot_glyphname_SOURCES = test-ot-glyphname.cc
|
||||
test_ot_glyphname_CPPFLAGS = $(HBCFLAGS)
|
||||
test_ot_glyphname_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
||||
test_gpos_size_params_SOURCES = test-gpos-size-params.cc
|
||||
test_gpos_size_params_CPPFLAGS = $(HBCFLAGS)
|
||||
test_gpos_size_params_LDADD = libharfbuzz.la $(HBLIBS)
|
||||
|
425
src/hb-ot-cff1-std-str.hh
Normal file
425
src/hb-ot-cff1-std-str.hh
Normal file
@ -0,0 +1,425 @@
|
||||
/*
|
||||
* Copyright © 2019 Adobe, Inc.
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that the
|
||||
* above copyright notice and the following two paragraphs appear in
|
||||
* all copies of this software.
|
||||
*
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
|
||||
#ifndef HB_OT_CFF1_STD_STR_HH
|
||||
#if 0 /* Make checks happy. */
|
||||
#define HB_OT_CFF1_STD_STR_HH
|
||||
#include "hb.hh"
|
||||
#endif
|
||||
|
||||
_S(".notdef")
|
||||
_S("space")
|
||||
_S("exclam")
|
||||
_S("quotedbl")
|
||||
_S("numbersign")
|
||||
_S("dollar")
|
||||
_S("percent")
|
||||
_S("ampersand")
|
||||
_S("quoteright")
|
||||
_S("parenleft")
|
||||
_S("parenright")
|
||||
_S("asterisk")
|
||||
_S("plus")
|
||||
_S("comma")
|
||||
_S("hyphen")
|
||||
_S("period")
|
||||
_S("slash")
|
||||
_S("zero")
|
||||
_S("one")
|
||||
_S("two")
|
||||
_S("three")
|
||||
_S("four")
|
||||
_S("five")
|
||||
_S("six")
|
||||
_S("seven")
|
||||
_S("eight")
|
||||
_S("nine")
|
||||
_S("colon")
|
||||
_S("semicolon")
|
||||
_S("less")
|
||||
_S("equal")
|
||||
_S("greater")
|
||||
_S("question")
|
||||
_S("at")
|
||||
_S("A")
|
||||
_S("B")
|
||||
_S("C")
|
||||
_S("D")
|
||||
_S("E")
|
||||
_S("F")
|
||||
_S("G")
|
||||
_S("H")
|
||||
_S("I")
|
||||
_S("J")
|
||||
_S("K")
|
||||
_S("L")
|
||||
_S("M")
|
||||
_S("N")
|
||||
_S("O")
|
||||
_S("P")
|
||||
_S("Q")
|
||||
_S("R")
|
||||
_S("S")
|
||||
_S("T")
|
||||
_S("U")
|
||||
_S("V")
|
||||
_S("W")
|
||||
_S("X")
|
||||
_S("Y")
|
||||
_S("Z")
|
||||
_S("bracketleft")
|
||||
_S("backslash")
|
||||
_S("bracketright")
|
||||
_S("asciicircum")
|
||||
_S("underscore")
|
||||
_S("quoteleft")
|
||||
_S("a")
|
||||
_S("b")
|
||||
_S("c")
|
||||
_S("d")
|
||||
_S("e")
|
||||
_S("f")
|
||||
_S("g")
|
||||
_S("h")
|
||||
_S("i")
|
||||
_S("j")
|
||||
_S("k")
|
||||
_S("l")
|
||||
_S("m")
|
||||
_S("n")
|
||||
_S("o")
|
||||
_S("p")
|
||||
_S("q")
|
||||
_S("r")
|
||||
_S("s")
|
||||
_S("t")
|
||||
_S("u")
|
||||
_S("v")
|
||||
_S("w")
|
||||
_S("x")
|
||||
_S("y")
|
||||
_S("z")
|
||||
_S("braceleft")
|
||||
_S("bar")
|
||||
_S("braceright")
|
||||
_S("asciitilde")
|
||||
_S("exclamdown")
|
||||
_S("cent")
|
||||
_S("sterling")
|
||||
_S("fraction")
|
||||
_S("yen")
|
||||
_S("florin")
|
||||
_S("section")
|
||||
_S("currency")
|
||||
_S("quotesingle")
|
||||
_S("quotedblleft")
|
||||
_S("guillemotleft")
|
||||
_S("guilsinglleft")
|
||||
_S("guilsinglright")
|
||||
_S("fi")
|
||||
_S("fl")
|
||||
_S("endash")
|
||||
_S("dagger")
|
||||
_S("daggerdbl")
|
||||
_S("periodcentered")
|
||||
_S("paragraph")
|
||||
_S("bullet")
|
||||
_S("quotesinglbase")
|
||||
_S("quotedblbase")
|
||||
_S("quotedblright")
|
||||
_S("guillemotright")
|
||||
_S("ellipsis")
|
||||
_S("perthousand")
|
||||
_S("questiondown")
|
||||
_S("grave")
|
||||
_S("acute")
|
||||
_S("circumflex")
|
||||
_S("tilde")
|
||||
_S("macron")
|
||||
_S("breve")
|
||||
_S("dotaccent")
|
||||
_S("dieresis")
|
||||
_S("ring")
|
||||
_S("cedilla")
|
||||
_S("hungarumlaut")
|
||||
_S("ogonek")
|
||||
_S("caron")
|
||||
_S("emdash")
|
||||
_S("AE")
|
||||
_S("ordfeminine")
|
||||
_S("Lslash")
|
||||
_S("Oslash")
|
||||
_S("OE")
|
||||
_S("ordmasculine")
|
||||
_S("ae")
|
||||
_S("dotlessi")
|
||||
_S("lslash")
|
||||
_S("oslash")
|
||||
_S("oe")
|
||||
_S("germandbls")
|
||||
_S("onesuperior")
|
||||
_S("logicalnot")
|
||||
_S("mu")
|
||||
_S("trademark")
|
||||
_S("Eth")
|
||||
_S("onehalf")
|
||||
_S("plusminus")
|
||||
_S("Thorn")
|
||||
_S("onequarter")
|
||||
_S("divide")
|
||||
_S("brokenbar")
|
||||
_S("degree")
|
||||
_S("thorn")
|
||||
_S("threequarters")
|
||||
_S("twosuperior")
|
||||
_S("registered")
|
||||
_S("minus")
|
||||
_S("eth")
|
||||
_S("multiply")
|
||||
_S("threesuperior")
|
||||
_S("copyright")
|
||||
_S("Aacute")
|
||||
_S("Acircumflex")
|
||||
_S("Adieresis")
|
||||
_S("Agrave")
|
||||
_S("Aring")
|
||||
_S("Atilde")
|
||||
_S("Ccedilla")
|
||||
_S("Eacute")
|
||||
_S("Ecircumflex")
|
||||
_S("Edieresis")
|
||||
_S("Egrave")
|
||||
_S("Iacute")
|
||||
_S("Icircumflex")
|
||||
_S("Idieresis")
|
||||
_S("Igrave")
|
||||
_S("Ntilde")
|
||||
_S("Oacute")
|
||||
_S("Ocircumflex")
|
||||
_S("Odieresis")
|
||||
_S("Ograve")
|
||||
_S("Otilde")
|
||||
_S("Scaron")
|
||||
_S("Uacute")
|
||||
_S("Ucircumflex")
|
||||
_S("Udieresis")
|
||||
_S("Ugrave")
|
||||
_S("Yacute")
|
||||
_S("Ydieresis")
|
||||
_S("Zcaron")
|
||||
_S("aacute")
|
||||
_S("acircumflex")
|
||||
_S("adieresis")
|
||||
_S("agrave")
|
||||
_S("aring")
|
||||
_S("atilde")
|
||||
_S("ccedilla")
|
||||
_S("eacute")
|
||||
_S("ecircumflex")
|
||||
_S("edieresis")
|
||||
_S("egrave")
|
||||
_S("iacute")
|
||||
_S("icircumflex")
|
||||
_S("idieresis")
|
||||
_S("igrave")
|
||||
_S("ntilde")
|
||||
_S("oacute")
|
||||
_S("ocircumflex")
|
||||
_S("odieresis")
|
||||
_S("ograve")
|
||||
_S("otilde")
|
||||
_S("scaron")
|
||||
_S("uacute")
|
||||
_S("ucircumflex")
|
||||
_S("udieresis")
|
||||
_S("ugrave")
|
||||
_S("yacute")
|
||||
_S("ydieresis")
|
||||
_S("zcaron")
|
||||
_S("exclamsmall")
|
||||
_S("Hungarumlautsmall")
|
||||
_S("dollaroldstyle")
|
||||
_S("dollarsuperior")
|
||||
_S("ampersandsmall")
|
||||
_S("Acutesmall")
|
||||
_S("parenleftsuperior")
|
||||
_S("parenrightsuperior")
|
||||
_S("twodotenleader")
|
||||
_S("onedotenleader")
|
||||
_S("zerooldstyle")
|
||||
_S("oneoldstyle")
|
||||
_S("twooldstyle")
|
||||
_S("threeoldstyle")
|
||||
_S("fouroldstyle")
|
||||
_S("fiveoldstyle")
|
||||
_S("sixoldstyle")
|
||||
_S("sevenoldstyle")
|
||||
_S("eightoldstyle")
|
||||
_S("nineoldstyle")
|
||||
_S("commasuperior")
|
||||
_S("threequartersemdash")
|
||||
_S("periodsuperior")
|
||||
_S("questionsmall")
|
||||
_S("asuperior")
|
||||
_S("bsuperior")
|
||||
_S("centsuperior")
|
||||
_S("dsuperior")
|
||||
_S("esuperior")
|
||||
_S("isuperior")
|
||||
_S("lsuperior")
|
||||
_S("msuperior")
|
||||
_S("nsuperior")
|
||||
_S("osuperior")
|
||||
_S("rsuperior")
|
||||
_S("ssuperior")
|
||||
_S("tsuperior")
|
||||
_S("ff")
|
||||
_S("ffi")
|
||||
_S("ffl")
|
||||
_S("parenleftinferior")
|
||||
_S("parenrightinferior")
|
||||
_S("Circumflexsmall")
|
||||
_S("hyphensuperior")
|
||||
_S("Gravesmall")
|
||||
_S("Asmall")
|
||||
_S("Bsmall")
|
||||
_S("Csmall")
|
||||
_S("Dsmall")
|
||||
_S("Esmall")
|
||||
_S("Fsmall")
|
||||
_S("Gsmall")
|
||||
_S("Hsmall")
|
||||
_S("Ismall")
|
||||
_S("Jsmall")
|
||||
_S("Ksmall")
|
||||
_S("Lsmall")
|
||||
_S("Msmall")
|
||||
_S("Nsmall")
|
||||
_S("Osmall")
|
||||
_S("Psmall")
|
||||
_S("Qsmall")
|
||||
_S("Rsmall")
|
||||
_S("Ssmall")
|
||||
_S("Tsmall")
|
||||
_S("Usmall")
|
||||
_S("Vsmall")
|
||||
_S("Wsmall")
|
||||
_S("Xsmall")
|
||||
_S("Ysmall")
|
||||
_S("Zsmall")
|
||||
_S("colonmonetary")
|
||||
_S("onefitted")
|
||||
_S("rupiah")
|
||||
_S("Tildesmall")
|
||||
_S("exclamdownsmall")
|
||||
_S("centoldstyle")
|
||||
_S("Lslashsmall")
|
||||
_S("Scaronsmall")
|
||||
_S("Zcaronsmall")
|
||||
_S("Dieresissmall")
|
||||
_S("Brevesmall")
|
||||
_S("Caronsmall")
|
||||
_S("Dotaccentsmall")
|
||||
_S("Macronsmall")
|
||||
_S("figuredash")
|
||||
_S("hypheninferior")
|
||||
_S("Ogoneksmall")
|
||||
_S("Ringsmall")
|
||||
_S("Cedillasmall")
|
||||
_S("questiondownsmall")
|
||||
_S("oneeighth")
|
||||
_S("threeeighths")
|
||||
_S("fiveeighths")
|
||||
_S("seveneighths")
|
||||
_S("onethird")
|
||||
_S("twothirds")
|
||||
_S("zerosuperior")
|
||||
_S("foursuperior")
|
||||
_S("fivesuperior")
|
||||
_S("sixsuperior")
|
||||
_S("sevensuperior")
|
||||
_S("eightsuperior")
|
||||
_S("ninesuperior")
|
||||
_S("zeroinferior")
|
||||
_S("oneinferior")
|
||||
_S("twoinferior")
|
||||
_S("threeinferior")
|
||||
_S("fourinferior")
|
||||
_S("fiveinferior")
|
||||
_S("sixinferior")
|
||||
_S("seveninferior")
|
||||
_S("eightinferior")
|
||||
_S("nineinferior")
|
||||
_S("centinferior")
|
||||
_S("dollarinferior")
|
||||
_S("periodinferior")
|
||||
_S("commainferior")
|
||||
_S("Agravesmall")
|
||||
_S("Aacutesmall")
|
||||
_S("Acircumflexsmall")
|
||||
_S("Atildesmall")
|
||||
_S("Adieresissmall")
|
||||
_S("Aringsmall")
|
||||
_S("AEsmall")
|
||||
_S("Ccedillasmall")
|
||||
_S("Egravesmall")
|
||||
_S("Eacutesmall")
|
||||
_S("Ecircumflexsmall")
|
||||
_S("Edieresissmall")
|
||||
_S("Igravesmall")
|
||||
_S("Iacutesmall")
|
||||
_S("Icircumflexsmall")
|
||||
_S("Idieresissmall")
|
||||
_S("Ethsmall")
|
||||
_S("Ntildesmall")
|
||||
_S("Ogravesmall")
|
||||
_S("Oacutesmall")
|
||||
_S("Ocircumflexsmall")
|
||||
_S("Otildesmall")
|
||||
_S("Odieresissmall")
|
||||
_S("OEsmall")
|
||||
_S("Oslashsmall")
|
||||
_S("Ugravesmall")
|
||||
_S("Uacutesmall")
|
||||
_S("Ucircumflexsmall")
|
||||
_S("Udieresissmall")
|
||||
_S("Yacutesmall")
|
||||
_S("Thornsmall")
|
||||
_S("Ydieresissmall")
|
||||
_S("001.000")
|
||||
_S("001.001")
|
||||
_S("001.002")
|
||||
_S("001.003")
|
||||
_S("Black")
|
||||
_S("Bold")
|
||||
_S("Book")
|
||||
_S("Light")
|
||||
_S("Medium")
|
||||
_S("Regular")
|
||||
_S("Roman")
|
||||
_S("Semibold")
|
||||
|
||||
#endif /* HB_OT_CFF1_STD_STR_HH */
|
@ -125,67 +125,6 @@ static const uint8_t standard_encoding_to_sid [] =
|
||||
0, 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/* SID to standard string */
|
||||
static const char *sid_to_standard_string [] =
|
||||
{
|
||||
".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent",
|
||||
"ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma",
|
||||
"hyphen", "period", "slash", "zero", "one", "two", "three",
|
||||
"four", "five", "six", "seven", "eight", "nine", "colon",
|
||||
"semicolon", "less", "equal", "greater", "question", "at", "A",
|
||||
"B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O",
|
||||
"P", "Q", "R", "S", "T", "U", "V",
|
||||
"W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright",
|
||||
"asciicircum", "underscore", "quoteleft", "a", "b", "c", "d",
|
||||
"e", "f", "g", "h", "i", "j", "k",
|
||||
"l", "m", "n", "o", "p", "q", "r",
|
||||
"s", "t", "u", "v", "w", "x", "y",
|
||||
"z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent",
|
||||
"sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle",
|
||||
"quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash",
|
||||
"dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase",
|
||||
"quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute",
|
||||
"circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring",
|
||||
"cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine",
|
||||
"Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash",
|
||||
"oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark",
|
||||
"Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar",
|
||||
"degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth",
|
||||
"multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave",
|
||||
"Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave",
|
||||
"Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex",
|
||||
"Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis",
|
||||
"Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis",
|
||||
"agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis",
|
||||
"egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute",
|
||||
"ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex",
|
||||
"udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall",
|
||||
"dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader",
|
||||
"onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle",
|
||||
"sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior",
|
||||
"questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior",
|
||||
"lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior",
|
||||
"ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior",
|
||||
"Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall",
|
||||
"Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall",
|
||||
"Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall",
|
||||
"Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary",
|
||||
"onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall",
|
||||
"Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash",
|
||||
"hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths",
|
||||
"fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior",
|
||||
"sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior",
|
||||
"threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior",
|
||||
"centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall",
|
||||
"Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall",
|
||||
"Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall",
|
||||
"Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall",
|
||||
"Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall",
|
||||
"Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold",
|
||||
"Book", "Light", "Medium", "Regular", "Roman", "Semibold"
|
||||
};
|
||||
|
||||
hb_codepoint_t OT::cff1::lookup_standard_encoding_for_code (hb_codepoint_t sid)
|
||||
{
|
||||
if (sid < ARRAY_LENGTH (standard_encoding_to_code))
|
||||
@ -226,14 +165,6 @@ hb_codepoint_t OT::cff1::lookup_standard_encoding_for_sid (hb_codepoint_t code)
|
||||
return CFF_UNDEF_SID;
|
||||
}
|
||||
|
||||
const char *OT::cff1::lookup_standard_string_for_sid (hb_codepoint_t sid)
|
||||
{
|
||||
if (sid < ARRAY_LENGTH (sid_to_standard_string))
|
||||
return sid_to_standard_string[sid];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
struct bounds_t
|
||||
{
|
||||
void init ()
|
||||
|
@ -31,6 +31,12 @@
|
||||
#include "hb-ot-cff-common.hh"
|
||||
#include "hb-subset-cff1.hh"
|
||||
|
||||
#define HB_STRING_ARRAY_NAME cff1_std_strings
|
||||
#define HB_STRING_ARRAY_LIST "hb-ot-cff1-std-str.hh"
|
||||
#include "hb-string-array.hh"
|
||||
#undef HB_STRING_ARRAY_LIST
|
||||
#undef HB_STRING_ARRAY_NAME
|
||||
|
||||
namespace CFF {
|
||||
|
||||
/*
|
||||
@ -40,7 +46,6 @@ namespace CFF {
|
||||
#define HB_OT_TAG_cff1 HB_TAG('C','F','F',' ')
|
||||
|
||||
#define CFF_UNDEF_SID CFF_UNDEF_CODE
|
||||
#define HB_CFF_STD_STR_COUNT 391
|
||||
|
||||
enum EncodingID { StandardEncoding = 0, ExpertEncoding = 1 };
|
||||
enum CharsetID { ISOAdobeCharset = 0, ExpertCharset = 1, ExpertSubsetCharset = 2 };
|
||||
@ -1264,6 +1269,31 @@ struct cff1
|
||||
|
||||
struct accelerator_t : accelerator_templ_t<cff1_private_dict_opset_t, cff1_private_dict_values_t>
|
||||
{
|
||||
void init (hb_face_t *face)
|
||||
{
|
||||
SUPER::init (face);
|
||||
|
||||
if (!is_valid ()) return;
|
||||
if (is_CID ()) return;
|
||||
|
||||
/* fill glyph_names */
|
||||
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
|
||||
{
|
||||
hb_codepoint_t sid = charset->get_sid (gid, num_glyphs);
|
||||
gname_t gname;
|
||||
gname.sid = sid;
|
||||
if (sid < cff1_std_strings_length)
|
||||
gname.name = cff1_std_strings (sid);
|
||||
else
|
||||
{
|
||||
byte_str_t ustr = (*stringIndex)[sid - cff1_std_strings_length];
|
||||
gname.name = hb_bytes_t ((const char*)ustr.arrayZ, ustr.length);
|
||||
}
|
||||
glyph_names.push (gname);
|
||||
}
|
||||
glyph_names.qsort ();
|
||||
}
|
||||
|
||||
bool get_glyph_name (hb_codepoint_t glyph,
|
||||
char *buf, unsigned int buf_len) const
|
||||
{
|
||||
@ -1271,19 +1301,19 @@ struct cff1
|
||||
if (unlikely (!is_valid ())) return false;
|
||||
if (is_CID()) return false;
|
||||
hb_codepoint_t sid = glyph_to_sid (glyph);
|
||||
byte_str_t byte_str;
|
||||
const char *str;
|
||||
size_t str_len;
|
||||
if (sid < HB_CFF_STD_STR_COUNT)
|
||||
if (sid < cff1_std_strings_length)
|
||||
{
|
||||
str = lookup_standard_string_for_sid (sid);
|
||||
str_len = strlen(str);
|
||||
hb_bytes_t byte_str = cff1_std_strings (sid);
|
||||
str = byte_str.arrayZ;
|
||||
str_len = byte_str.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte_str = (*stringIndex)[sid - HB_CFF_STD_STR_COUNT];
|
||||
str = (const char *)byte_str.arrayZ;
|
||||
str_len = byte_str.length;
|
||||
byte_str_t ubyte_str = (*stringIndex)[sid - cff1_std_strings_length];
|
||||
str = (const char *)ubyte_str.arrayZ;
|
||||
str_len = ubyte_str.length;
|
||||
}
|
||||
if (!str_len) return false;
|
||||
unsigned int len = hb_min (buf_len - 1, str_len);
|
||||
@ -1292,8 +1322,46 @@ struct cff1
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get_glyph_from_name (const char *name, int len,
|
||||
hb_codepoint_t *glyph) const
|
||||
{
|
||||
if (len < 0) len = strlen (name);
|
||||
if (unlikely (!len)) return false;
|
||||
|
||||
gname_t key = { hb_bytes_t (name, len), 0 };
|
||||
const gname_t *gname = glyph_names.bsearch (key);
|
||||
if (gname == nullptr) return false;
|
||||
hb_codepoint_t gid = charset->get_glyph (gname->sid, num_glyphs);
|
||||
if (!gid && gname->sid) return false;
|
||||
*glyph = gid;
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
|
||||
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
|
||||
|
||||
private:
|
||||
struct gname_t
|
||||
{
|
||||
hb_bytes_t name;
|
||||
uint16_t sid;
|
||||
|
||||
static int cmp (const void *a_, const void *b_)
|
||||
{
|
||||
const gname_t *a = (const gname_t *)a_;
|
||||
const gname_t *b = (const gname_t *)b_;
|
||||
int minlen = hb_min (a->name.length, b->name.length);
|
||||
int ret = strncmp (a->name.arrayZ, b->name.arrayZ, minlen);
|
||||
if (ret) return ret;
|
||||
return a->name.length - b->name.length;
|
||||
}
|
||||
|
||||
int cmp (const gname_t &a) const { return cmp (&a, this); }
|
||||
};
|
||||
|
||||
hb_sorted_vector_t<gname_t> glyph_names;
|
||||
|
||||
typedef accelerator_templ_t<cff1_private_dict_opset_t, cff1_private_dict_values_t> SUPER;
|
||||
};
|
||||
|
||||
struct accelerator_subset_t : accelerator_templ_t<cff1_private_dict_opset_subset, cff1_private_dict_values_subset_t> {};
|
||||
@ -1322,7 +1390,6 @@ struct cff1
|
||||
HB_INTERNAL static hb_codepoint_t lookup_expert_charset_for_sid (hb_codepoint_t glyph);
|
||||
HB_INTERNAL static hb_codepoint_t lookup_expert_subset_charset_for_sid (hb_codepoint_t glyph);
|
||||
HB_INTERNAL static hb_codepoint_t lookup_standard_encoding_for_sid (hb_codepoint_t code);
|
||||
HB_INTERNAL static const char *lookup_standard_string_for_sid (hb_codepoint_t sid);
|
||||
|
||||
public:
|
||||
FixedVersion<HBUINT8> version; /* Version of CFF table. set to 0x0100u */
|
||||
|
@ -224,7 +224,11 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
|
||||
return ot_face->post->get_glyph_from_name (name, len, glyph);
|
||||
hb_bool_t ret = ot_face->post->get_glyph_from_name (name, len, glyph);
|
||||
#ifndef HB_NO_OT_FONT_CFF
|
||||
if (!ret) ret = ot_face->cff1->get_glyph_from_name (name, len, glyph);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
91
src/test-ot-glyphname.cc
Normal file
91
src/test-ot-glyphname.cc
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright © 2019 Adobe, Inc.
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that the
|
||||
* above copyright notice and the following two paragraphs appear in
|
||||
* all copies of this software.
|
||||
*
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
* Adobe Author(s): Michiharu Ariza
|
||||
*/
|
||||
|
||||
#include "hb.hh"
|
||||
#include "hb-ot.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HB_NO_OPEN
|
||||
#define hb_blob_create_from_file(x) hb_blob_get_empty ()
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
fprintf (stderr, "usage: %s font-file\n", argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
|
||||
hb_face_t *face = hb_face_create (blob, 0 /* first face */);
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_blob_destroy (blob);
|
||||
blob = nullptr;
|
||||
|
||||
|
||||
const unsigned int num_glyphs = hb_face_get_glyph_count (face);
|
||||
int result = 1;
|
||||
|
||||
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
|
||||
{
|
||||
char buf[64];
|
||||
unsigned int buf_size = sizeof (buf);
|
||||
if (hb_font_get_glyph_name (font, gid, buf, buf_size))
|
||||
{
|
||||
hb_codepoint_t gid_inv;
|
||||
if (hb_font_get_glyph_from_name(font, buf, strlen (buf), &gid_inv))
|
||||
{
|
||||
if (gid == gid_inv)
|
||||
{
|
||||
printf ("%u <-> %s\n", gid, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%u -> %s -> %u\n", gid, buf, gid_inv);
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%u -> %s -> ?\n", gid, buf);
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%u -> ?\n", gid);
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue
Block a user