From baf822d197397902d99e83257a75d043e7f2f30c Mon Sep 17 00:00:00 2001 From: "smontagu%netscape.com" Date: Mon, 7 Oct 2002 21:08:10 +0000 Subject: [PATCH] Add support for Adobe's Type1 Euro fonts. Bug 158129, author=Roland.Mainz@informatik.med.uni-giessen.de, r=bstell, sr=roc+moz --- gfx/src/gtk/nsFontMetricsGTK.cpp | 50 +++++++++++++--- gfx/src/xlib/nsFontMetricsXlib.cpp | 50 +++++++++++++--- intl/uconv/src/nsUConvModule.cpp | 6 ++ intl/uconv/ucvlatin/Makefile.in | 1 + intl/uconv/ucvlatin/adobeeuro.uf | 60 +++++++++++++++++++ intl/uconv/ucvlatin/nsUCvLatinCID.h | 4 ++ intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.cpp | 63 ++++++++++++++++++++ intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.h | 53 ++++++++++++++++ 8 files changed, 273 insertions(+), 14 deletions(-) create mode 100644 intl/uconv/ucvlatin/adobeeuro.uf create mode 100644 intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.cpp create mode 100644 intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.h diff --git a/gfx/src/gtk/nsFontMetricsGTK.cpp b/gfx/src/gtk/nsFontMetricsGTK.cpp index c9a60cc0dfb7..ababf8d2267c 100644 --- a/gfx/src/gtk/nsFontMetricsGTK.cpp +++ b/gfx/src/gtk/nsFontMetricsGTK.cpp @@ -350,6 +350,9 @@ static nsFontCharSetInfo ISO106461 = static nsFontCharSetInfo AdobeSymbol = { "Adobe-Symbol-Encoding", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0 }; +static nsFontCharSetInfo AdobeEuro = + { "x-adobe-euro", SingleByteConvert, 0, + 0, 0 }; #ifdef MOZ_MATHML static nsFontCharSetInfo CMCMEX = @@ -553,6 +556,9 @@ static nsFontCharSetMap gNoneCharSetMap[] = { { nsnull }, }; static nsFontCharSetMap gSpecialCharSetMap[] = { { "symbol-adobe-fontspecific", &FLG_NONE, &AdobeSymbol }, + { "euromono-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, + { "eurosans-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, + { "euroserif-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, #ifdef MOZ_MATHML { "cmex10-adobe-fontspecific", &FLG_NONE, &CMCMEX }, @@ -621,11 +627,34 @@ static PRUint16* gDoubleByteSpecialCharsCCMap = nsnull; // fonts are too large to use is western fonts. // Here we define those characters. // -static PRUnichar gDoubleByteSpecialChars[] = { - 0x0152, 0x0153, 0x0160, 0x0161, 0x0178, 0x017D, 0x017E, 0x0192, - 0x02C6, 0x02DC, 0x2013, 0x2014, 0x2018, 0x2019, 0x201A, 0x201C, - 0x201D, 0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039, - 0x203A, 0x20AC, 0x2122, +static const PRUnichar gDoubleByteSpecialChars[] = { + 0x0152, /* LATIN CAPITAL LIGATURE OE */ + 0x0153, /* LATIN SMALL LIGATURE OE */ + 0x0160, /* LATIN CAPITAL LETTER S WITH CARON */ + 0x0161, /* LATIN SMALL LETTER S WITH CARON */ + 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ + 0x017D, /* LATIN CAPITAL LETTER Z WITH CARON */ + 0x017E, /* LATIN SMALL LETTER Z WITH CARON */ + 0x0192, /* LATIN SMALL LETTER F WITH HOOK */ + 0x02C6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */ + 0x02DC, /* SMALL TILDE */ + 0x2013, /* EN DASH */ + 0x2014, /* EM DASH */ + 0x2018, /* LEFT SINGLE QUOTATION MARK */ + 0x2019, /* RIGHT SINGLE QUOTATION MARK */ + 0x201A, /* SINGLE LOW-9 QUOTATION MARK */ + 0x201C, /* LEFT DOUBLE QUOTATION MARK */ + 0x201D, /* RIGHT DOUBLE QUOTATION MARK */ + 0x201E, /* DOUBLE LOW-9 QUOTATION MARK */ + 0x2020, /* DAGGER */ + 0x2021, /* DOUBLE DAGGER */ + 0x2022, /* BULLET */ + 0x2026, /* HORIZONTAL ELLIPSIS */ + 0x2030, /* PER MILLE SIGN */ + 0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */ + 0x203A, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */ + 0x20AC, /* EURO SIGN */ + 0x2122, /* TRADE MARK SIGN */ 0 }; @@ -4612,8 +4641,12 @@ if (gAllowDoubleByteSpecialChars) { // add the symbol font before the early transliterator // to get the bullet (hack) - nsCAutoString ffre("*-symbol-adobe-fontspecific"); - nsFontGTK* symbol_font = TryNodes(ffre, 0x0030); + nsCAutoString symbol_ffre("*-symbol-adobe-fontspecific"); + nsFontGTK* symbol_font = TryNodes(symbol_ffre, 0x0030); + + // Add the Adobe Euro fonts before the early transliterator + nsCAutoString euro_ffre("*-euro*-adobe-fontspecific"); + nsFontGTK* euro_font = TryNodes(euro_ffre, 0x20AC); // add the early transliterator // to avoid getting Japanese "special chars" such as smart @@ -4630,6 +4663,9 @@ if (gAllowDoubleByteSpecialChars) { else if (symbol_font && CCMAP_HAS_CHAR(symbol_font->mCCMap, aChar)) { return symbol_font; } + else if (euro_font && CCMAP_HAS_CHAR(euro_font->mCCMap, aChar)) { + return euro_font; + } else if (sub_font && CCMAP_HAS_CHAR(sub_font->mCCMap, aChar)) { FIND_FONT_PRINTF((" transliterate special chars for single byte docs")); return sub_font; diff --git a/gfx/src/xlib/nsFontMetricsXlib.cpp b/gfx/src/xlib/nsFontMetricsXlib.cpp index 724ea6284704..db80fe474acd 100644 --- a/gfx/src/xlib/nsFontMetricsXlib.cpp +++ b/gfx/src/xlib/nsFontMetricsXlib.cpp @@ -392,6 +392,9 @@ static nsFontCharSetInfoXlib ISO106461 = static nsFontCharSetInfoXlib AdobeSymbol = { "Adobe-Symbol-Encoding", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0 }; +static nsFontCharSetInfoXlib AdobeEuro = + { "x-adobe-euro", SingleByteConvert, 0, + 0, 0 }; #ifdef MOZ_MATHML static nsFontCharSetInfoXlib CMCMEX = @@ -595,6 +598,9 @@ static nsFontCharSetMapXlib gNoneCharSetMap[] = { { nsnull }, }; static nsFontCharSetMapXlib gSpecialCharSetMap[] = { { "symbol-adobe-fontspecific", &FLG_NONE, &AdobeSymbol }, + { "euromono-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, + { "eurosans-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, + { "euroserif-adobe-fontspecific", &FLG_NONE, &AdobeEuro }, #ifdef MOZ_MATHML { "cmex10-adobe-fontspecific", &FLG_NONE, &CMCMEX }, @@ -663,11 +669,34 @@ static PRUint16* gDoubleByteSpecialCharsCCMap = nsnull; // fonts are too large to use is western fonts. // Here we define those characters. // -static PRUnichar gDoubleByteSpecialChars[] = { - 0x0152, 0x0153, 0x0160, 0x0161, 0x0178, 0x017D, 0x017E, 0x0192, - 0x02C6, 0x02DC, 0x2013, 0x2014, 0x2018, 0x2019, 0x201A, 0x201C, - 0x201D, 0x201E, 0x2020, 0x2021, 0x2022, 0x2026, 0x2030, 0x2039, - 0x203A, 0x20AC, 0x2122, +static const PRUnichar gDoubleByteSpecialChars[] = { + 0x0152, /* LATIN CAPITAL LIGATURE OE */ + 0x0153, /* LATIN SMALL LIGATURE OE */ + 0x0160, /* LATIN CAPITAL LETTER S WITH CARON */ + 0x0161, /* LATIN SMALL LETTER S WITH CARON */ + 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ + 0x017D, /* LATIN CAPITAL LETTER Z WITH CARON */ + 0x017E, /* LATIN SMALL LETTER Z WITH CARON */ + 0x0192, /* LATIN SMALL LETTER F WITH HOOK */ + 0x02C6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */ + 0x02DC, /* SMALL TILDE */ + 0x2013, /* EN DASH */ + 0x2014, /* EM DASH */ + 0x2018, /* LEFT SINGLE QUOTATION MARK */ + 0x2019, /* RIGHT SINGLE QUOTATION MARK */ + 0x201A, /* SINGLE LOW-9 QUOTATION MARK */ + 0x201C, /* LEFT DOUBLE QUOTATION MARK */ + 0x201D, /* RIGHT DOUBLE QUOTATION MARK */ + 0x201E, /* DOUBLE LOW-9 QUOTATION MARK */ + 0x2020, /* DAGGER */ + 0x2021, /* DOUBLE DAGGER */ + 0x2022, /* BULLET */ + 0x2026, /* HORIZONTAL ELLIPSIS */ + 0x2030, /* PER MILLE SIGN */ + 0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */ + 0x203A, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */ + 0x20AC, /* EURO SIGN */ + 0x2122, /* TRADE MARK SIGN */ 0 }; @@ -5081,8 +5110,12 @@ if (gAllowDoubleByteSpecialChars) { // add the symbol font before the early transliterator // to get the bullet (hack) - nsCAutoString ffre("*-symbol-adobe-fontspecific"); - nsFontXlib* symbol_font = TryNodes(ffre, 0x0030); + nsCAutoString symbol_ffre("*-symbol-adobe-fontspecific"); + nsFontXlib* symbol_font = TryNodes(symbol_ffre, 0x0030); + + // Add the Adobe Euro fonts before the early transliterator + nsCAutoString euro_ffre("*-euro*-adobe-fontspecific"); + nsFontXlib* euro_font = TryNodes(euro_ffre, 0x20AC); // add the early transliterator // to avoid getting Japanese "special chars" such as smart @@ -5099,6 +5132,9 @@ if (gAllowDoubleByteSpecialChars) { else if (symbol_font && CCMAP_HAS_CHAR(symbol_font->mCCMap, aChar)) { return symbol_font; } + else if (euro_font && CCMAP_HAS_CHAR(euro_font->mCCMap, aChar)) { + return euro_font; + } else if (sub_font && CCMAP_HAS_CHAR(sub_font->mCCMap, aChar)) { FIND_FONT_PRINTF((" transliterate special chars for single byte docs")); return sub_font; diff --git a/intl/uconv/src/nsUConvModule.cpp b/intl/uconv/src/nsUConvModule.cpp index 7306105c893c..f7a4bca5ac60 100644 --- a/intl/uconv/src/nsUConvModule.cpp +++ b/intl/uconv/src/nsUConvModule.cpp @@ -186,6 +186,7 @@ #include "nsUnicodeToUserDefined.h" #include "nsUnicodeToSymbol.h" #include "nsUnicodeToZapfDingbat.h" +#include "nsUnicodeToAdobeEuro.h" #include "nsMacArabicToUnicode.h" #include "nsMacDevanagariToUnicode.h" #include "nsMacFarsiToUnicode.h" @@ -1281,6 +1282,11 @@ static const nsModuleComponentInfo components[] = NS_UNICODEENCODER_CONTRACTID_BASE "x-zapf-dingbats", nsUnicodeToZapfDingbatConstructor, }, + { + ENCODER_NAME_BASE "x-adobe-euro", NS_UNICODETOADOBEEURO_CID, + NS_UNICODEENCODER_CONTRACTID_BASE "x-adobe-euro", + nsUnicodeToAdobeEuroConstructor, + }, { ENCODER_NAME_BASE "x-mac-arabic" , NS_UNICODETOMACARABIC_CID, NS_UNICODEENCODER_CONTRACTID_BASE "x-mac-arabic", diff --git a/intl/uconv/ucvlatin/Makefile.in b/intl/uconv/ucvlatin/Makefile.in index 81689dc470b5..61fc91c34e7b 100644 --- a/intl/uconv/ucvlatin/Makefile.in +++ b/intl/uconv/ucvlatin/Makefile.in @@ -160,6 +160,7 @@ CPPSRCS = \ nsUnicodeToUserDefined.cpp \ nsUnicodeToSymbol.cpp \ nsUnicodeToZapfDingbat.cpp \ + nsUnicodeToAdobeEuro.cpp \ $(NULL) EXPORTS = nsUCvLatinCID.h diff --git a/intl/uconv/ucvlatin/adobeeuro.uf b/intl/uconv/ucvlatin/adobeeuro.uf new file mode 100644 index 000000000000..dec4e20cbdef --- /dev/null +++ b/intl/uconv/ucvlatin/adobeeuro.uf @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +* +* The contents of this file are subject to the Netscape Public License +* Version 1.0 (the "NPL"); you may not use this file except in +* compliance with the NPL. You may obtain a copy of the NPL at +* http://www.mozilla.org/NPL/ +* +* Software distributed under the NPL is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL +* for the specific language governing rights and limitations under the +* NPL. +* +* The Initial Developer of this code under the NPL is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 2001 Netscape Communications Corporation. All Rights +* Reserved. +*/ + /*======================================================== + This is a Generated file. Please don't edit it. + + The tool which used to generate this file is called umaptable. + You can find this tool under mozilla/intl/uconv/tools/umaptable.c. + If you have any problem of this file. Please contact + Netscape Client International Team or + ftang@netscape + + Table in Debug form +Begin of Item 0000 + Format 2 + srcBegin = 20AC + destBegin = 00A4 +End of Item 0000 + +========================================================*/ +/* Offset=0x0000 ItemOfList */ + 0x0001, +/*-------------------------------------------------------*/ +/* Offset=0x0001 offsetToFormatArray */ + 0x0004, +/*-------------------------------------------------------*/ +/* Offset=0x0002 offsetToMapCellArray */ + 0x0005, +/*-------------------------------------------------------*/ +/* Offset=0x0003 offsetToMappingTable */ + 0x0008, +/*-------------------------------------------------------*/ +/* Offset=0x0004 Start of Format Array */ +/* Total of Format 0 : 0x0000 */ +/* Total of Format 1 : 0x0000 */ +/* Total of Format 2 : 0x0001 */ +/* Total of Format 3 : 0x0000 */ + +0x0002, +/*-------------------------------------------------------*/ +/* Offset=0x0005 Start of MapCell Array */ +/* 0000 */ 0x20AC, 0x0000, 0x00A4, +/*-------------------------------------------------------*/ +/* Offset=0x0008 Start of MappingTable */ + +/* End of table Total Length = 0x0008 * 2 */ diff --git a/intl/uconv/ucvlatin/nsUCvLatinCID.h b/intl/uconv/ucvlatin/nsUCvLatinCID.h index e9bccd89694a..f67c1eada00f 100644 --- a/intl/uconv/ucvlatin/nsUCvLatinCID.h +++ b/intl/uconv/ucvlatin/nsUCvLatinCID.h @@ -585,6 +585,10 @@ #define NS_UNICODETOZAPFDINGBATS_CID \ { 0x21dd6a03, 0x413c, 0x11d3, {0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}} +// Class ID for our UnicodeToAscii charset converter +#define NS_UNICODETOADOBEEURO_CID \ + { 0x822cb9ae, 0x6421, 0x4484, {0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}} + // {4F26B731-46CB-11d3-B3C3-00805F8A6670} #define NS_UNICODETOTIS620WIN_CID \ { 0x4f26b731, 0x46cb, 0x11d3, {0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}} diff --git a/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.cpp b/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.cpp new file mode 100644 index 000000000000..be8a820cafb6 --- /dev/null +++ b/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.cpp @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (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.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Roland Mainz + * . + * All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsUCConstructors.h" +#include "nsUnicodeToAdobeEuro.h" + +//---------------------------------------------------------------------- +// Global functions and data [declaration] + +static const PRUint16 g_ufMappingTable[] = { +/* "adobeeuro.uf" was generated like this: + * % echo '0xA4 0x20AC # EURO CURRENCY SIGN' | ./umaptable -uf >adobeeuro.uf + */ +#include "adobeeuro.uf" +}; + +static const PRInt16 g_ufShiftTable[] = { + 0, u1ByteCharset , + ShiftCell(0,0,0,0,0,0,0,0) +}; + +NS_METHOD +nsUnicodeToAdobeEuroConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + return CreateTableEncoder((uShiftTable*) &g_ufShiftTable, + (uMappingTable*) &g_ufMappingTable, 1, + aOuter, aIID, aResult); +} diff --git a/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.h b/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.h new file mode 100644 index 000000000000..cc6af9e73d9c --- /dev/null +++ b/intl/uconv/ucvlatin/nsUnicodeToAdobeEuro.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (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.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is + * The Initial Developer of the Original Code is Roland Mainz + * . + * All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsUnicodeToAdobeEuro_h___ +#define nsUnicodeToAdobeEuro_h___ 1 + +#include "nsISupports.h" + +/** + * A character set converter from Unicode to Adobe Euro + * (see http://bugzilla.mozilla.org/show_bug.cgi?id=158129 for details). + * + */ +NS_METHOD +nsUnicodeToAdobeEuroConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult); + +#endif /* !nsUnicodeToAdobeEuro_h___ */