找回密码
 注册
查看: 1136|回复: 0

请教mozilla patch问题

[复制链接]
发表于 2003-5-30 22:04:45 | 显示全部楼层 |阅读模式
我想仅patch显示中文名,而不修改下画线,该怎么修改版主的这个patch呢?

--- mozilla/gfx/src/gtk/nsFontMetricsXft.cpp.orig        2003-04-07 20:51:35.000000000 +0800
+++ mozilla/gfx/src/gtk/nsFontMetricsXft.cpp        2003-04-08 10:00:22.000000000 +0800
@@ -796,7 +796,7 @@
     if (lineHeight > mEmHeight)
         mLeading = lineHeight - mEmHeight;
     else
-        mLeading = 0;
+        mLeading = (int)(f * 3); /* 列距為 3 條 pixels */

     // mMaxHeight (needs ascent and descent)
     mMaxHeight = lineHeight;
@@ -834,14 +834,9 @@
     mXHeight = nscoord(mXHeight * f);

     // mUnderlineOffset (offset for underlines)
-    val = face->underline_position >> 16;
-    if (val) {
-        mUnderlineOffset = NSToIntRound(val * f);
-    }
-    else {
-        mUnderlineOffset =
+    // 底線在字的下面, 而不是疊在字的最後一條線
+    mUnderlineOffset = (int)-(f) +
             -NSToIntRound(PR_MAX(1, floor(0.1 * xftFont->height + 0.5)) * f);
-    }

     // mUnderlineSize (thickness of an underline)
     val = face->underline_thickness >> 16;
@@ -1921,8 +1916,29 @@
             goto end;

         PRUnichar *r = name;
-        for (char *f = family; *f; ++f)
-            *r++ = *f;
+        unsigned char c;
+        int pi = 0;
+        // 處理字型名稱, 可含有 UTF8
+        for (char *f = family; *f; ++f) {
+          c = *f;
+          if ((c & 0x80) == 0) {
+            *r++ = c;
+          } else if ((c & 0xf0) == 0xf0) {
+            continue;
+          } else if ((c & 0xf0) == 0xe0) {
+            pi = 2;
+            *r = c & 0xf;
+          } else if ((c & 0xe0) == 0xc0) {
+            pi = 1;
+            *r = c & 0x1f;
+          } else if (pi > 0) {
+            *r = ((*r) << 6) | (c & 0x3f);
+            if (--pi == 0) {
+              r++;
+            }
+          }
+        }
+
         *r = '\0';

         array[narray++] = name;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-11 08:29 , Processed in 0.052274 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表