2015-10-20 42 views
0

在Android應用上,我將信用卡條目設置爲四個EditText字段。這些字段被配置爲使用等寬字體。Nexus 5等寬字體對於unicode圈具有不同的寬度

當我輸入數字時,每個4個字符塊的寬度始終相同。

但是,要掩蓋已輸入的信用卡詳細信息,請使用unicode黑色圓圈字符「●」。事實證明,即使使用等寬字體,「●●●●」的寬度也比「1111」寬。當我試圖支持不同的系統字體大小和屏幕大小時,這會導致我出現問題。

Monospaced circle vs numbers

有趣的是,在Nexus 5棉花糖,或奇巧三星手機,我沒有看到這個問題!

我錯過了什麼,或者是棒棒糖上的默認Android等寬字體,實際上沒有等寬?

我的XML:

 <LinearLayout 
     android:id="@+id/card_number_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center"> 

     <EditText 
      android:id="@+id/card_field_1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:hint="●●●●" 
      android:typeface="monospace" 
      android:inputType="number" 
      android:focusable="true" 
      android:maxLength="4"> 
     </EditText> 

     ... 
     </LinearLayout> 
+0

我注意到在棉花糖類似的問題,線描人物沒有等寬。這主要表現在我使用Connectbot並使用這些字符運行終端會話時;框和列不與文本對齊。這使得一些屏幕無法使用;我可能會降級回KitKat。 – hyc

+0

在我的Droid4上運行KitKat,沒有問題。在我的Nook HD +上運行CyanogenMod 13(Marshmallow)等寬體是不對的。我也檢查了我的Geekbox運行棒棒糖,那裏的問題。我也嘗試將舊版本的DroidSansMono.ttf加載到我的Nook(來自Android源代碼樹https://github.com/android/platform_frameworks_base/tree/master/data/fonts),但即使使用KitKat版本的字體也沒有'不改變任何事情。它似乎正在使用其他字體而不是DroidSansMono.ttf。 /system/etc/fonts.xml在Nexus 5上的外觀是什麼? – hyc

+0

我發現在KitKat中,畫線字符來自DroidSansFallback.ttf--這個文件在我的棉花糖版本上完全沒有。而且,這些字符在Github上的最新版本的DroidSansFallback中缺失。相反,Noto *系列的其他字體正在用於這些字符。如果我隱藏所有Noto *字體並安裝KitKat DroidSansFallback.ttf,那麼我會正確排列線條繪製字符。 – hyc

回答

3

在我的棉花糖構建這些圖形字符從NotoSansSymbols-常規Subsetted.ttf來了,他們絕對不是等寬。谷歌搞砸了。隱藏該文件並使用Kitkat中的DroidSansFallback.ttf使事情爲我排隊。

我在這裏提交bug報告https://github.com/googlei18n/noto-fonts/issues/617