mirror of
https://github.com/sojamo/controlp5
synced 2024-11-25 15:17:57 +01:00
parent
cc775e7e31
commit
02b34a6fa6
@ -2,9 +2,9 @@ package controlP5;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* controlP5 is a processing gui library.
|
* controlP5 is a processing gui library.
|
||||||
*
|
*
|
||||||
* 2006-2015 by Andreas Schlegel
|
* 2006-2015 by Andreas Schlegel
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
* as published by the Free Software Foundation; either version 2.1
|
* as published by the Free Software Foundation; either version 2.1
|
||||||
@ -13,16 +13,16 @@ package controlP5;
|
|||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General
|
* You should have received a copy of the GNU Lesser General
|
||||||
* Public License along with this library; if not, write to the
|
* Public License along with this library; if not, write to the
|
||||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
* Boston, MA 02111-1307 USA
|
* Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* @author Andreas Schlegel (http://www.sojamo.de)
|
* @author Andreas Schlegel (http://www.sojamo.de)
|
||||||
* @modified ##date##
|
* @modified ##date##
|
||||||
* @version ##version##
|
* @version ##version##
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -39,7 +39,7 @@ import processing.core.PGraphics;
|
|||||||
* dimensions of a font which are not available at all times but only at certain times. The current
|
* dimensions of a font which are not available at all times but only at certain times. The current
|
||||||
* status I suppose is a good compromise and works for standard font handling cases. For any special
|
* status I suppose is a good compromise and works for standard font handling cases. For any special
|
||||||
* cases it will be difficult to convince me to make any changes.)
|
* cases it will be difficult to convince me to make any changes.)
|
||||||
*
|
*
|
||||||
* @example extra/ControlP5controlFont
|
* @example extra/ControlP5controlFont
|
||||||
*/
|
*/
|
||||||
public class ControlFont {
|
public class ControlFont {
|
||||||
@ -198,7 +198,8 @@ public class ControlFont {
|
|||||||
myString = w + " ";
|
myString = w + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt.add( myString.substring( 0 , myString.length( ) - 1 ) );
|
//txt.add( myString.substring( 0 , myString.length( ) - 1 ) );
|
||||||
|
txt.add( myString.substring( 0 , PApplet.max( 0 , myString.length( ) - 1 ) ) );
|
||||||
myString = "";
|
myString = "";
|
||||||
}
|
}
|
||||||
if ( theLabel.getHeight( ) % theLabel.getLineHeight( ) != 0 ) {
|
if ( theLabel.getHeight( ) % theLabel.getLineHeight( ) != 0 ) {
|
||||||
@ -223,7 +224,7 @@ public class ControlFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw( PGraphics theGraphics , Label theLabel ) {
|
public void draw( PGraphics theGraphics , Label theLabel ) {
|
||||||
|
|
||||||
PFont loadedFont = theGraphics.textFont;
|
PFont loadedFont = theGraphics.textFont;
|
||||||
float loadedSize = theGraphics.textSize;
|
float loadedSize = theGraphics.textSize;
|
||||||
if ( loadedFont == null ) {
|
if ( loadedFont == null ) {
|
||||||
@ -232,7 +233,7 @@ public class ControlFont {
|
|||||||
}
|
}
|
||||||
int loadedAlign = theGraphics.textAlign;
|
int loadedAlign = theGraphics.textAlign;
|
||||||
|
|
||||||
|
|
||||||
theGraphics.textFont( pfont , size );
|
theGraphics.textFont( pfont , size );
|
||||||
theGraphics.textAlign( theLabel.textAlign );
|
theGraphics.textAlign( theLabel.textAlign );
|
||||||
theGraphics.fill( theLabel.getColor( ) );
|
theGraphics.fill( theLabel.getColor( ) );
|
||||||
@ -241,7 +242,7 @@ public class ControlFont {
|
|||||||
theGraphics.textLeading( theLabel.getLineHeight( ) );
|
theGraphics.textLeading( theLabel.getLineHeight( ) );
|
||||||
theGraphics.text( s , 0 , 0 , theLabel.getWidth( ) , theLabel.getHeight( ) );
|
theGraphics.text( s , 0 , 0 , theLabel.getWidth( ) , theLabel.getHeight( ) );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
theGraphics.translate( 0 , -top + 1 );
|
theGraphics.translate( 0 , -top + 1 );
|
||||||
debug( theGraphics , theLabel );
|
debug( theGraphics , theLabel );
|
||||||
theGraphics.fill( theLabel.getColor( ) );
|
theGraphics.fill( theLabel.getColor( ) );
|
||||||
@ -250,12 +251,12 @@ public class ControlFont {
|
|||||||
if ( RENDER_2X ) {
|
if ( RENDER_2X ) {
|
||||||
theGraphics.text( theLabel.getTextFormatted( ) , 0 , 0 );
|
theGraphics.text( theLabel.getTextFormatted( ) , 0 , 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theGraphics.textFont( loadedFont , loadedSize );
|
theGraphics.textFont( loadedFont , loadedSize );
|
||||||
theGraphics.textAlign( loadedAlign );
|
theGraphics.textAlign( loadedAlign );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void debug( PGraphics theGraphics , Label theLabel ) {
|
private void debug( PGraphics theGraphics , Label theLabel ) {
|
||||||
@ -289,4 +290,3 @@ public class ControlFont {
|
|||||||
|
|
||||||
// textorize, a Ruby-based font rasterizer command line utility for Mac OS X
|
// textorize, a Ruby-based font rasterizer command line utility for Mac OS X
|
||||||
// http://textorize.org/
|
// http://textorize.org/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user