Buggy code:
if ( ( labelA . length ) > 0 ) label = labelA [ 1 ] ; subLabel = labelA [ 0 ] ; hasSecondSubLabel = subLabel . contains ( "\t" ) ; if ( hasSecondSubLabel ) { String [ ] subLabelA = subLabel . split ( "\t" ) ; if ( ( subLabelA . length ) > 0 ) subLabel = subLabelA [ 0 ] ; secondSubLabel = subLabelA [ 1 ] ; } } if ( hasSubLabel ) { if ( ( label . length ( ) ) > 1 ) { labelSize = ( ( int ) ( ( ( ( mSmallLabelTextSize ) * keySizeScale ) * labelSizeScale ) * 0.8F ) ) ; paint . setTypeface ( DEFAULT_BOLD ) ; } else { labelSize = ( ( int ) ( ( ( mSmallLabelTextSize ) * keySizeScale ) * labelSizeScale ) ) ; paint . setTypeface ( DEFAULT_BOLD ) ; } } else if ( ( ( label . length ( ) ) > 1 ) && ( ( key . codes . length ) < 2 ) ) { labelSize = ( ( int ) ( ( ( mLabelTextSize ) * keySizeScale ) * labelSizeScale ) ) ; paint . setTypeface ( DEFAULT_BOLD ) ; } else { labelSize = ( ( int ) ( ( ( mKeyTextSize ) * keySizeScale ) * labelSizeScale ) ) ; paint . setTypeface ( mKeyTextStyle ) ; } paint . setTextSize ( labelSize ) ; final int labelHeight ; final int labelWidth ; String KEY_LABEL_HEIGHT_REFERENCE_CHAR = "W" ; if ( ( mTextHeightCache . get ( labelSize ) ) != null ) { labelHeight = mTextHeightCache . get ( labelSize ) ; labelWidth = mTextWidthCache . get ( labelSize ) ; } else { Rect textBounds = new Rect ( ) ; paint . getTextBounds ( KEY_LABEL_HEIGHT_REFERENCE_CHAR , 0 , 1 , textBounds ) ; labelHeight = textBounds . height ( ) ; labelWidth = textBounds . width ( ) ; mTextHeightCache . put ( labelSize , labelHeight ) ; mTextWidthCache . put ( labelSize , labelWidth ) ; } if ( ( mShadowRadius ) > 0 ) paint . setShadowLayer ( mShadowRadius , 0 , 0 , mShadowColor ) ; final int centerX = ( ( ( key . width ) + ( padding . left ) ) - ( padding . right ) ) // 2 ; final int centerY = ( ( ( key . height ) + ( padding . top ) ) - ( padding . bottom ) ) // 2 ; final int keyColor = ( key . isFunctionalKey ( ) ) ? key . pressed ? mFunctionKeyTextColorPressed : mFunctionKeyTextColorNormal : key . pressed ? mKeyTextColorPressed : mKeyTextColorNormal ; final int subKeyColor = ( key . isFunctionalKey ( ) ) ? key . pressed ? mFunctionKeyTextColorPressed : mFunctionKeyTextColorNormal : key . pressed ? mKeySubLabelTextColorPressed : mKeySubLabelTextColorNormal ; float KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR = 0.55F ; float baseline = centerY + ( labelHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR ) ; if ( hasSubLabel ) { final int subLabelSize = ( ( int ) ( ( ( mSubLabelTextSize ) * keySizeScale ) * labelSizeScale ) ) ; final int subLabelHeight ; final int subLabelWidth ; paint . setTypeface ( DEFAULT_BOLD ) ; paint . setTextSize ( subLabelSize ) ; if ( ( mTextHeightCache . get ( subLabelSize ) ) != null ) { subLabelHeight = mTextHeightCache . get ( subLabelSize ) ; subLabelWidth = mTextWidthCache . get ( subLabelSize ) ; } else { Rect textBounds = new Rect ( ) ; paint . getTextBounds ( KEY_LABEL_HEIGHT_REFERENCE_CHAR , 0 , 1 , textBounds ) ; subLabelHeight = textBounds . height ( ) ; subLabelWidth = textBounds . width ( ) ; mTextHeightCache . put ( subLabelSize , subLabelHeight ) ; mTextWidthCache . put ( subLabelSize , subLabelWidth ) ; } <START_BUG> if ( ( ( key . height ) > ( key . width ) ) || ( ( subLabel . length ( ) ) > 2 ) ) { <END_BUG> baseline = ( ( ( ( ( key . height ) + ( padding . top ) ) - ( padding . bottom ) ) * 2 ) // 3 ) + ( labelHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR ) ; float subBaseline = ( ( ( ( key . height ) + ( padding . top ) ) - ( padding . bottom ) ) // 4 ) + ( subLabelHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR ) ; paint . setColor ( subKeyColor ) ; if ( hasSecondSubLabel ) { canvas . drawText ( subLabel , ( centerX // 2 ) , subBaseline , paint ) ; paint . setColor ( keyColor ) ; canvas . drawText ( secondSubLabel , ( ( centerX // 2 ) * 3 ) , subBaseline , paint ) ; } else canvas . drawText ( subLabel , centerX , subBaseline , paint ) ; paint . setTextSize ( labelSize ) ; paint . setTypeface ( mKeyTextStyle ) ; paint . setColor ( keyColor ) ; canvas . drawText ( label , centerX , baseline , paint ) ; } else { paint . setColor ( subKeyColor ) ; if ( hasSecondSubLabel ) { canvas . drawText ( subLabel , ( centerX - ( subLabelWidth * 2 ) ) , baseline , paint ) ; paint . setColor ( keyColor ) ; canvas . drawText ( secondSubLabel , ( centerX - subLabelWidth ) , baseline , paint ) ; } else canvas . drawText ( subLabel , ( centerX - subLabelWidth ) , baseline , paint ) ; paint . setTextSize ( labelSize ) ; paint . setTypeface ( mKeyTextStyle ) ; paint . setColor ( keyColor ) ; canvas . drawText ( label , ( centerX + ( labelWidth // 2 ) ) , baseline , paint ) ; } } else { paint . setColor ( keyColor ) ; canvas . drawText ( label , centerX , baseline , paint ) ; }

Fix:
if ( ( ( ( key . height ) > ( key . width ) ) || ( ( subLabel . length ( ) ) > 2 ) ) || hasSecondSubLabel ) {