Flex/Flash font style viewer–Flex/Flash字体预览器

Categories: Flex; Tagged with: ; @ November 6th, 2011 22:22

Based on your fonts installed on your local machine, view the font style.

image

Link: http://liguoliang.com/pub/utils/FlashFontStyleViewer.html

Code:

// handle click, get the info, and generate Labels.
		protected function buttonPreview_clickHandler(event:MouseEvent):void {
			var textFontFamilyRaw:String = textFontFamily.text == null ? "" : StringUtils.trim(textFontFamily.text);
			if(StringUtils.isWhiteSpace(textFontFamilyRaw)) {
				Alert.show("Please input some font-family");
				return;
			}
			
			var arrayFontFamily:Array = textFontFamilyRaw.split("\n");
			var textDisplay:String = textToView.text;
			if(textDisplay == null || StringUtils.isEmptyString(textDisplay)) {
				textDisplay = "Flex上海用户组";
			}
			var fontSize:int = comboBoxFontSize.selectedItem as int;
			
			showPreview(arrayFontFamily, fontSize,textDisplay, checkBoxIsBold.selected);
			
		}
		
		// For each font-family, create a Label and set style, add all labels on stage.
		private function showPreview(arrayFontFamily:Array, fontSize:int = 12, text:String="Flex上海用户组", isBold:Boolean= false):void {
			vGroupLabels.removeAllElements();
			for each(var fontFamily:String in arrayFontFamily) {
				var label:Label = new Label();
				label.text = text + "[" + fontFamily + " - " + fontSize + "pt]";
				label.setStyle(FlexConstants.STYLE_FONT_FAMILY, fontFamily);
				label.setStyle(FlexConstants.STYLE_FONT_SIZE, fontSize);
				if(isBold) {
					label.setStyle(FlexConstants.STYLE_FONT_WEIGHT, "bold");
					label.text += "  - Bold";
				}
				vGroupLabels.addElement(label);
			}
		}



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.