Commit 0d410376 authored by Albert Astals Cid's avatar Albert Astals Cid

Gfx8BitFont: Make multiple code variables instead of one

Makes for easier understanding/scoping of its value
parent 308b7ca1
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed // All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later // under GPL version 2 or later
// //
// Copyright (C) 2005, 2006, 2008-2010, 2012, 2014, 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2006, 2008-2010, 2012, 2014, 2015, 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
...@@ -953,7 +953,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -953,7 +953,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
int len; int len;
FoFiType1 *ffT1; FoFiType1 *ffT1;
FoFiType1C *ffT1C; FoFiType1C *ffT1C;
int code;
char *charName; char *charName;
bool missing, hex; bool missing, hex;
bool numeric; bool numeric;
...@@ -1213,7 +1212,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1213,7 +1212,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
if (obj2.isArray()) { if (obj2.isArray()) {
encodingName->Set("Custom"); encodingName->Set("Custom");
hasEncoding = true; hasEncoding = true;
code = 0; int code = 0;
for (i = 0; i < obj2.arrayGetLength(); ++i) { for (i = 0; i < obj2.arrayGetLength(); ++i) {
Object obj3 = obj2.arrayGet(i); Object obj3 = obj2.arrayGet(i);
if (obj3.isInt()) { if (obj3.isInt()) {
...@@ -1243,7 +1242,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1243,7 +1242,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
// pass 1: use the name-to-Unicode mapping table // pass 1: use the name-to-Unicode mapping table
missing = hex = false; missing = hex = false;
bool isZapfDingbats = name && name->endsWith("ZapfDingbats"); bool isZapfDingbats = name && name->endsWith("ZapfDingbats");
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
if ((charName = enc[code])) { if ((charName = enc[code])) {
if (isZapfDingbats) { if (isZapfDingbats) {
// include ZapfDingbats names // include ZapfDingbats names
...@@ -1284,7 +1283,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1284,7 +1283,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
// pass 1a: Expand ligatures in the Alphabetic Presentation Form // pass 1a: Expand ligatures in the Alphabetic Presentation Form
// block (eg "fi", "ffi") to normal form // block (eg "fi", "ffi") to normal form
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
if (unicodeIsAlphabeticPresentationForm(toUnicode[code])) { if (unicodeIsAlphabeticPresentationForm(toUnicode[code])) {
Unicode *normalized = unicodeNormalizeNFKC(&toUnicode[code], 1, &len, nullptr); Unicode *normalized = unicodeNormalizeNFKC(&toUnicode[code], 1, &len, nullptr);
if (len > 1) if (len > 1)
...@@ -1296,7 +1295,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1296,7 +1295,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
// pass 2: try to fill in the missing chars, looking for ligatures, numeric // pass 2: try to fill in the missing chars, looking for ligatures, numeric
// references and variants // references and variants
if (missing) { if (missing) {
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
if (!toUnicode[code]) { if (!toUnicode[code]) {
if ((charName = enc[code]) && strcmp(charName, ".notdef") if ((charName = enc[code]) && strcmp(charName, ".notdef")
&& (n = parseCharName(charName, uBuf, sizeof(uBuf)/sizeof(*uBuf), && (n = parseCharName(charName, uBuf, sizeof(uBuf)/sizeof(*uBuf),
...@@ -1326,7 +1325,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1326,7 +1325,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
//----- get the character widths ----- //----- get the character widths -----
// initialize all widths // initialize all widths
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
widths[code] = missingWidth * 0.001; widths[code] = missingWidth * 0.001;
} }
...@@ -1348,7 +1347,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1348,7 +1347,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
if (obj1.arrayGetLength() < lastChar - firstChar + 1) { if (obj1.arrayGetLength() < lastChar - firstChar + 1) {
lastChar = firstChar + obj1.arrayGetLength() - 1; lastChar = firstChar + obj1.arrayGetLength() - 1;
} }
for (code = firstChar; code <= lastChar; ++code) { for (int code = firstChar; code <= lastChar; ++code) {
Object obj2 = obj1.arrayGet(code - firstChar); Object obj2 = obj1.arrayGet(code - firstChar);
if (obj2.isNum()) { if (obj2.isNum()) {
widths[code] = obj2.getNum() * mul; widths[code] = obj2.getNum() * mul;
...@@ -1365,7 +1364,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1365,7 +1364,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
if (builtinFont->widths->getWidth("space", &w)) { if (builtinFont->widths->getWidth("space", &w)) {
widths[32] = 0.001 * w; widths[32] = 0.001 * w;
} }
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) {
widths[code] = 0.001 * w; widths[code] = 0.001 * w;
} }
...@@ -1395,7 +1394,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA ...@@ -1395,7 +1394,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA
if (builtinFont->widths->getWidth("space", &w)) { if (builtinFont->widths->getWidth("space", &w)) {
widths[32] = 0.001 * w; widths[32] = 0.001 * w;
} }
for (code = 0; code < 256; ++code) { for (int code = 0; code < 256; ++code) {
if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) { if (enc[code] && builtinFont->widths->getWidth(enc[code], &w)) {
widths[code] = 0.001 * w; widths[code] = 0.001 * w;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment