mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
temporarily add options to prefs to choose flags passed to Paint for
drawing text; improve calc of textHeight to better fill cell. Still need to detect dicts where descent isn't used, e.g. hex
This commit is contained in:
parent
8b84bdf56e
commit
3ca7f84659
3 changed files with 45 additions and 15 deletions
|
@ -223,6 +223,11 @@
|
|||
<string name="msg_dup_room">Another host has already registered a room using that name. Rename yours or retry later.</string>
|
||||
<string name="msg_lost_other">The relay has lost contact with another device in this game.</string>
|
||||
|
||||
<string name="ids_badwords">Word[s] %s not found in dictionary.</string>
|
||||
<string name="badwords_accept"> Do you still want to accept this move?</string>
|
||||
<string name="badwords_lost"> Turn lost.</string>
|
||||
<string name="badwords_title">Illegal word[s]</string>
|
||||
|
||||
<!-- These do not require localization -->
|
||||
<string name="key_color_tiles">key_color_tiles</string>
|
||||
<string name="key_show_arrow">key_show_arrow</string>
|
||||
|
@ -243,5 +248,8 @@
|
|||
<string name="key_relay_port">key_relay_port</string>
|
||||
<string name="key_sms_port">key_sms_port</string>
|
||||
|
||||
<string name="key_anti_alias">key_anti_alias</string>
|
||||
<string name="key_subpixel">key_subpixel</string>
|
||||
|
||||
<string name="default_host">eehouse.org</string>
|
||||
</resources>
|
||||
|
|
|
@ -43,15 +43,14 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private int m_dictPtr = 0;
|
||||
private int m_lastSecsLeft;
|
||||
private class FontDims {
|
||||
FontDims( int topRow, int bottomRow, int width ) {
|
||||
m_topRow = topRow;
|
||||
m_bottomRow = bottomRow;
|
||||
m_textHeight = bottomRow - topRow + 1;
|
||||
FontDims( int boundsHt, int drawnHt, int topRow, int bottomRow,
|
||||
int width ) {
|
||||
float textHeight = bottomRow - topRow;
|
||||
m_textHeight = (int)Math.floor((boundsHt * textHeight) / drawnHt);
|
||||
|
||||
m_width = width;
|
||||
}
|
||||
int m_textHeight;
|
||||
int m_topRow;
|
||||
int m_bottomRow;
|
||||
int m_width;
|
||||
}
|
||||
FontDims m_cellDims;
|
||||
|
@ -119,7 +118,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private void init()
|
||||
{
|
||||
m_drawPaint = new Paint();
|
||||
m_fillPaint = new Paint();
|
||||
m_fillPaint = new Paint( CommonPrefs.getFontFlags() );
|
||||
m_strokePaint = new Paint();
|
||||
m_strokePaint.setStyle( Paint.Style.STROKE );
|
||||
m_tileStrokePaint = new Paint();
|
||||
|
@ -526,13 +525,13 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
m_canvas.drawRect( rect, m_fillPaint );
|
||||
}
|
||||
|
||||
private FontDims getFontDims( int ht, int width )
|
||||
private FontDims getFontDims( final int ht, final int width )
|
||||
{
|
||||
Utils.logf( "getFontDims(" + ht + ")" );
|
||||
int ascent;
|
||||
int useHt;
|
||||
|
||||
Paint paint = new Paint();
|
||||
Paint paint = new Paint(); // CommonPrefs.getFontFlags()??
|
||||
paint.setStyle( Paint.Style.STROKE );
|
||||
paint.setTextAlign( Paint.Align.LEFT );
|
||||
for ( useHt = ht; ; --useHt ) {
|
||||
|
@ -549,7 +548,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
|
||||
ascent = -fmi.ascent;
|
||||
if ( useHt + fmi.descent <= ht ) {
|
||||
// Utils.logf( "going with ht: " + useHt );
|
||||
Utils.logf( "going with ht: " + useHt );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -602,9 +601,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
}
|
||||
|
||||
Utils.logf( "topRow: " + topRow + "; bottomRow: " + bottomRow );
|
||||
|
||||
return new FontDims( topRow, bottomRow, maxWidth );
|
||||
return new FontDims( ht, useHt, topRow, bottomRow, maxWidth );
|
||||
} // getFontDims
|
||||
|
||||
private void figureTrayTxtHts( Rect rect )
|
||||
|
@ -614,7 +611,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
|
||||
private void figureCellTxtHt( Rect rect )
|
||||
{
|
||||
m_cellDims = getFontDims( rect.height(), rect.width() );
|
||||
m_cellDims = getFontDims( rect.height()-2, rect.width()-2 );
|
||||
}
|
||||
|
||||
private void markBlank( Rect rect )
|
||||
|
|
|
@ -5,9 +5,12 @@ package org.eehouse.android.xw4.jni;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.eehouse.android.xw4.R;
|
||||
import android.graphics.Paint;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
||||
public class CommonPrefs {
|
||||
public static final int COLOR_TILE_BACK = 0;
|
||||
public static final int COLOR_FOCUS = 1;
|
||||
|
@ -119,4 +122,26 @@ public class CommonPrefs {
|
|||
String key = s_context.getString( R.string.key_relay_host );
|
||||
return sp.getString( key, "" );
|
||||
}
|
||||
|
||||
public static int getFontFlags()
|
||||
{
|
||||
String key;
|
||||
int result = 0;
|
||||
SharedPreferences sp =
|
||||
PreferenceManager.getDefaultSharedPreferences( s_context );
|
||||
|
||||
key = s_context.getString( R.string.key_anti_alias );
|
||||
if ( sp.getBoolean( key, false ) ) {
|
||||
result = Paint.ANTI_ALIAS_FLAG | result;
|
||||
}
|
||||
|
||||
key = s_context.getString( R.string.key_subpixel );
|
||||
if ( sp.getBoolean( key, false ) ) {
|
||||
result = Paint.SUBPIXEL_TEXT_FLAG | result;
|
||||
}
|
||||
|
||||
Utils.logf( "getFontFlags=>" + result );
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue